tcp socket send - Resource temporarily unavailable?

  • Thread starter =?ISO-8859-15?Q?Bastian_P=F6ttner?=
  • Start date
?

=?ISO-8859-15?Q?Bastian_P=F6ttner?=

Hey guys,


I am currently trying my best to implement a simple TCP Server in c++.
It waits for connections of clients and sends out files on request.

I made the socket non blocking since I want to do other stuff while no
data is being sent.

My problem is: Whenever I transfer a larger amount of data, the send
call returns a length that is smaller than I wanted to send. I suspect
that this is because of the TCP send buffer which might have run out of
space.

My question is: How can I avoid sending incomplete "messages" using TCP?
Is there any way to determine the space left in the send buffer? Or
should I switch to blocking operation? How would I use select to figure
out if data is available for reading?


Thanks for your help,

Bastian
 
?

=?ISO-8859-15?Q?Bastian_P=F6ttner?=

Bastian said:
I am currently trying my best to implement a simple TCP Server in c++.
It waits for connections of clients and sends out files on request.

Well, two more important things:

linux 2.6 and gcc. ;)


Bastian
 
I

Ian Collins

Bastian said:
Hey guys,


I am currently trying my best to implement a simple TCP Server in c++.
It waits for connections of clients and sends out files on request.

I made the socket non blocking since I want to do other stuff while no
data is being sent.

My problem is: Whenever I transfer a larger amount of data, the send
call returns a length that is smaller than I wanted to send. I suspect
that this is because of the TCP send buffer which might have run out of
space.
This is OT here, try comp.unix.programmer, or the winsock equivalent if
you are stuck with windows.
 
J

Jim Langston

Bastian Pöttner said:
Hey guys,


I am currently trying my best to implement a simple TCP Server in c++. It
waits for connections of clients and sends out files on request.

I made the socket non blocking since I want to do other stuff while no
data is being sent.

My problem is: Whenever I transfer a larger amount of data, the send call
returns a length that is smaller than I wanted to send. I suspect that
this is because of the TCP send buffer which might have run out of space.

My question is: How can I avoid sending incomplete "messages" using TCP?
Is there any way to determine the space left in the send buffer? Or should
I switch to blocking operation? How would I use select to figure out if
data is available for reading?

A bit off topic, but TCP/IP is a stream. Basically, if you are trying to
send, say, 10,000 bytes, and it says it sent 4,000, then set your data
pointer to byte 4001 and send again, repeat until all the data is sent.
 
P

Peter

Hey guys,

I am currently trying my best to implement a simple TCP Server in c++.
It waits for connections of clients and sends out files on request.

I made the socket non blocking since I want to do other stuff while no
data is being sent.

My problem is: Whenever I transfer a larger amount of data, the send
call returns a length that is smaller than I wanted to send. I suspect
that this is because of the TCP send buffer which might have run out of
space.

My question is: How can I avoid sending incomplete "messages" using TCP?
Is there any way to determine the space left in the send buffer? Or
should I switch to blocking operation? How would I use select to figure
out if data is available for reading?

Thanks for your help,

Bastian

use select or epool to multiplexing on I/O handles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top