C
cerr
Hi There,
I'm very new to Python and i wanna write a script that sends a certain
string to a server. The code I came up with looks like this:
#!/usr/bin/python
import sys
import string
from socket import *
usage="USAGE: "+sys.argv[0]+" <server> <port>";
if len(sys.argv) != 3:
print usage;
sys.exit(0);
host = sys.argv[1];
port = sys.argv[2];
buf = 1024;
addr = (host,port);
sock = socket(AF_INET, SOCK_STREAM);
data = string.join("NovaxTest",'\n');
sock.send(data);
sock.close();
and I'm calling this script like that: "./TestService.py 127.0.0.1
1514" but when I call it I get following back:
sending data to 127.0.0.1:1514
data: NovaxTest
Traceback (most recent call last):
File "./TestService.py", line 18, in <module>
sock.send(data);
socket.error: [Errno 32] Broken pipe
I understand that UNIX sends an Errno32 if the server closes the
connection. But if i telnet to localhost on 1514 and send NovaxTest by
hand everything works just fine. So what might be wrong here?
Thank you very much!
Ron
I'm very new to Python and i wanna write a script that sends a certain
string to a server. The code I came up with looks like this:
#!/usr/bin/python
import sys
import string
from socket import *
usage="USAGE: "+sys.argv[0]+" <server> <port>";
if len(sys.argv) != 3:
print usage;
sys.exit(0);
host = sys.argv[1];
port = sys.argv[2];
buf = 1024;
addr = (host,port);
sock = socket(AF_INET, SOCK_STREAM);
data = string.join("NovaxTest",'\n');
sock.send(data);
sock.close();
and I'm calling this script like that: "./TestService.py 127.0.0.1
1514" but when I call it I get following back:
sending data to 127.0.0.1:1514
data: NovaxTest
Traceback (most recent call last):
File "./TestService.py", line 18, in <module>
sock.send(data);
socket.error: [Errno 32] Broken pipe
I understand that UNIX sends an Errno32 if the server closes the
connection. But if i telnet to localhost on 1514 and send NovaxTest by
hand everything works just fine. So what might be wrong here?
Thank you very much!
Ron