By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,022 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,022 IT Pros & Developers. It's quick & easy.

tcp socket send - Resource temporarily unavailable?

P: n/a
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
Jun 13 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bastian Pöttner schrieb:
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
Jun 13 '07 #2

P: n/a
Bastian Pöttner wrote:
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.

--
Ian Collins.
Jun 13 '07 #3

P: n/a
"Bastian Pöttner" <Ba*****@Poettner.dewrote in message
news:46**********************@newsspool2.arcor-online.net...
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.
Jun 14 '07 #4

P: n/a
On Jun 14, 7:14 am, Bastian Pöttner <Bast...@Poettner.dewrote:
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.

Jun 14 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.