I have a few questions. send is supposed to return the total number of bytes sent (if no error occurs). If I send 1024 bytes and send returns a value of 500 bytes, does this mean that the first 500 bytes in a 1024 byte buffer were sent or that 500 bytes were sent, not necessarily in order?

Also, while studying some other code related to this matter I noticed that some people send data to remote socket without checking that the socket is ready for writing (by using FD_WRITE flag). Is there any safe place to send data without checking the readiness for writing or the action must be triggered with FD_WRITE.

What is the most efficient size of package to be transmitted and what does it depend on?

If I use multiple connections to remote host (one for receiving and one for sending), will that ease the job of sending/receiving data? Will those sockets interefere each other?
Posted on 2001-12-24 19:37:03 by Ivan Stambuk
Originally posted by Ivan Stambuk
I have a few questions. send is supposed to return the total number of bytes sent (if no error occurs). If I send 1024 bytes and send returns a value of 500 bytes, does this mean that the first 500 bytes in a 1024 byte buffer were sent or that 500 bytes were sent, not necessarily in order?

The former, it means the first 500 bytes were sent successfully.


Also, while studying some other code related to this matter I noticed that some people send data to remote socket without checking that the socket is ready for writing (by using FD_WRITE flag). Is there any safe place to send data without checking the readiness for writing or the action must be triggered with FD_WRITE.

You are allowed to call send at any point in your program. When the socket was ready for writing, the data will be sent correctly. However when it wasn't, it fails with an WSAEWOULDBLOCK error, and nothing is sent.
In *both* cases, wheter send succeeds or fails, a new FD_WRITE message is sent. Use this as a trigger to send the rest/more data.


What is the most efficient size of package to be transmitted and what does it depend on?

When using streaming sockets, winsock takes care of this (see also this thread), so don't bother about the packet size. Winsock will optimize the packages for you.


If I use multiple connections to remote host (one for receiving and one for sending), will that ease the job of sending/receiving data? Will those sockets interefere each other?

They won't interfere as they use seperate connections, but why create two sockets? One connection with one socket (on each side of course), has two-way communication. You can send and receive on both sides. Using seperate connections for sending and receiving will definitely not ease your task.

Thomas
Posted on 2001-12-25 04:51:05 by Thomas
Some download managers (like Download Acelerator Plus) use multiple connections to the server to accelerate the downloading. If I break the data I want to send in 4 pieces and send each one separately, will that accelerate the sending?
Posted on 2001-12-25 08:29:36 by Ivan Stambuk

Some download managers (like Download Acelerator Plus) use multiple connections to the server to accelerate the downloading. If I break the data I want to send in 4 pieces and send each one separately, will that accelerate the sending?


It depends on the connection and the server. The acceleration is mainly because of the restrictions some servers have (say max 20kb/s per connection), and because accelerators often use multiple servers that host the same file.
But for a something like a local network, it won't give much improvement. It all depends on the maximum bandwidth of both connections (server & client).

Thomas
Posted on 2001-12-25 09:43:53 by Thomas
Can you tell me where can I found examples on writing Winsock applications in MASM syntax? I already have some basic examples (most of which are trojans:grin: , btw), and those C++ stuff that can be found all over the Web is not the right template to start with. Any URL is highly appreciated.
Posted on 2001-12-25 17:46:07 by Ivan Stambuk
There are some examples at Iczelion's site (http://win32asm.cjb.net), and some in several threads like these:

http://www.asmcommunity.net/board/index.php?topic=1874

http://www.asmcommunity.net/board/index.php?topic=2086

Thomas
Posted on 2001-12-26 05:49:05 by Thomas