Re: [PHP] Socket problem plz read.



Németh Zoltán wrote:
On sze, 2007-01-31 at 16:26 +0100, Scripter47 wrote:
I'm making a simple socket server that just receive some data, and then
send some data back again to the client.

EDIT:
I forgot to tell that i need help!

I have search around for hours now, and the examples are always not what
I needed :(

the program is written in Python, if that helps, and is something like this

this is PHP list. go to Python list with that, I suggest

greets
Zoltán Németh

The script the OP is connecting to is a PHP script, so assuming it's that script that the OP is having problems with it's kinda relevant.

To the OP: Your Python script is wrong. The host should just be localhost. You are trying to mix HTTP and UDP, and it's never going to work.

For the PHP side, read the manual (http://php.net/socket_create), have a go and come back if/when you have problems.

But before you do that, make sure the Python side is right, for which you'll need a Python mailing list.

-Stut

<code>
# Set the socket parameters
host = "http://localhost/in/sql.php";
port = 10000
buf = 10000
addr = (host,port)

# Create socket
UDPSock = socket(AF_INET, SOCK_DGRAM)

# Send messages:

# Loop
while (1):
# userinput
data = raw_input('>> ')
if not data:
break
else:
# Send to the PHP page
if(UDPSock.sendto(data,addr)):
print "Sending message '",data,"'....."

# Close socket
UDPSock.close()
</code>

it is a program that send data by sockets, (not port 80)

It has to a simple solution :)

plz ask for more information.




--
_________ .__ __ ______________
/ _____/ ___________|__|______/ |_ ___________ / | \______ \
\_____ \_/ ___\_ __ \ \____ \ __\/ __ \_ __ \/ | |_ / /
/ \ \___| | \/ | |_> > | \ ___/| | \/ ^ / / /
/_______ /\___ >__| |__| __/|__| \___ >__| \____ | /____/
\/ \/ |__| \/ |__|


.



Relevant Pages

  • Re: Persistent connections
    ... What happens if more than one web client (that includes the code ... If the collection script is invoked via a browser, ... command-line PHP script subjects it to a different limit which might ... instead of opening the socket. ...
    (comp.lang.php)
  • Re: Persistent connections
    ... POST to open socket to get data flowing; ... What happens if more than one web client (that includes the code ... If the collection script is invoked via a browser, ... command-line PHP script subjects it to a different limit which might ...
    (comp.lang.php)
  • Re: Re[2]: [PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?
    ... would you agree with this guy's comments concerning low- level PHP socket functions vs stream_socket_server? ... "If you want a high speed socket server, use the low-level sockets instead. ... And it stays high until I stop the script and restart it. ...
    (php.general)
  • Re: Python as replacement for PHP?
    ... > advice about PHP vs. Python, in general and particularly on the following ... I know there is postgres support in python however with zope we have worked ... > allows Apache to foist off an HTTP request on a Python script to handle I ...
    (comp.lang.python)
  • Python as replacement for PHP?
    ... HTML using PHP. ... I am advocating considering switching to Python for a number of ... HTTP requests) in one language. ... functions from a Python script? ...
    (comp.lang.php)