Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I wrote an internet server socket (SOCK_STREAM) and a client. After a connect() in the client, I wrote a loop to do a send() followed by a recv(), in another word, I'll send a msg, get a reply back from the server, then do it again... 5 times in total. The first time it went OK, but when it looped back, it failed at the recv(). The error is "socket is reset by peer".
Then I changed the code, each time I will do: connect()-send()-recv()-close(), then again...for 5 times. This works fine.
So I am wondering, for a client socket, if it can only recv() once, and I'll have to close it then connect() again to send-recv another msg? It doesn't sound right...

If you are using a stream socket then you will only have to connect once. Once the connection is built up you can send and receive as much as you want either from the server side or the client side.
I don't know what your code looks like so I can't really guess what's going wrong.
I never use send and recv but they should work just fine. I use read and write.Mik

i think this should work fine in loop also..
c if u r making some other mistake..
i have worked with send and recv and these things do work fine...

sir...
my project is web enable control system ...
i want that whatever data i take the
from the remote sight that shoul be copy on remote sight ..in the same formate so i required socket programming...and code for that can you help me out ..thanking you
sandeep

sir...
my project is web enable control system ...in which person who is on the remote sight can operate the equipments through net.
i want that whatever data i take from the
from the remote sight that shoul be copy on server sight ..in the same formate so ican check the operation from the same file and perform the operation so it required socket programming...and code for that can you help me out ..thanking you
sandeep

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |