python s.send > c tcpServer
I am trying to send data to a simple tcpServer ( from pont.net/sockets) using the Python.
The connection is established but the tcpserver doesn't show any data being sent. It's waiting for something. I tried s.send("7/r/n/") but I believe it wants an end of line / end of buffer statement, and that the connection should then be closed. I tried s.close() but then it just froze up. The code for the tcpclient (that I know) sends what's needed has : send(sd, argv[i], strlen(argv[i]) + 1, 0) but I'm not sure how to interpret it. |
s.send( "9\0", 0) is what was needed to send a 9,
s.send( "3\0", 0) to send a 3, etc. |
where's your connect code?
|
Which connect code?
Code:
#!/usr/bin/env python Code:
def togglebutton1_pressed(self, widget): Code:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
Not really good at python, but I think you should be flushing the data..:-?
|
if I remember correctly you need to provide 's', possibly two ways?
Code:
def togglebutton1_pressed(self, widget): Code:
def togglebutton1_pressed(self, widget): (p.s. I may be very wrong, lol, but I can't see rest of code!) |
how shall I flush?
How do you mean 'flush the data'? Client side, I was relying on the built in garbage collection. Server side the program is a C echo server, do you think it needs some additional info?
|
I don't know about python very well, but generally, to ensure that data is sent immediately, one must flush it. For instance, in C you would create a file stream from your socket and then you would write to that file. To make sure it sent it, you would call fflush. Again, I don't know if this is the case with your program. Another thing I suggest is trying to connect with telnet to your server. See what happens. If it doesn't work from there either then you know the problem is on the otherside. Cheers:)
|
The program was working fine. The second posting of mine was just to show how I fixed the problem.
Thank you. |
All times are GMT -5. The time now is 04:29 PM. |