Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Multiple writes to client socket

Reply
Thread Tools

Multiple writes to client socket

 
 
Daniel Draper
Guest
Posts: n/a
 
      04-02-2005
Hi,

I have a written a simple client server app using sockets in c. My
client code works great for a single send/recv operation but as soon
as I try to write (send) to the same socket again the server does not
receive the data.

My client code looks like this:

sock = make_socket (PORT);

for (i = 0; i < 2; i++)
{
send(sock, MESSAGE, strlen(MESSAGE) + 1, 0);

n = recv(sock, buf, sizeof(buf), 0);
if (n > 0)
printf("server echoed %s\n", buf);
}

close(sock);

First iteration works, but second fails.

Any ideas?

Daniel
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      04-02-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) (Daniel Draper) writes:
> I have a written a simple client server app using sockets in c.

[snip]
> Any ideas?


Yes. Try a newsgroup specific to your operating system (perhaps
comp.unix.programmer).

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Nitin
Guest
Posts: n/a
 
      04-04-2005
What is this sizeof ( buf ).. it might be that sizeof(buf) is much
larger than strlen(MESSAGE) so it might be w8ing to read sizeof(buf)
from the the socket.

 
Reply With Quote
 
Peter Nilsson
Guest
Posts: n/a
 
      04-04-2005
Nitin wrote:
> What is this sizeof ( buf ) ...


Who knows? You haven't quoted the message you're replying to,
so anyone who didn't get the original has NO IDEA what you're
talking about.

Since you're using Google, please take notice of...

'If you want to post a followup via groups.google.com,
don't use the broken "Reply" link at the bottom of the
article. Click on "show options" at the top of the
article, then click on the "Reply" at the bottom of the
article headers.' - Keith Thompson

--
Peter

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments