{L}
"M.S.Reddy" <msr...@indiatimes.com> wrote in message
news:1-ednQkxMoi...@comcast.com...
Just so I understand, you want to have the socket blocking, but be
temporarily non-blocking for one or two function calls? What is it you're
trying to accomplish? Perhaps there is a better way.
{L}
"M.S.Reddy" <msr...@indiatimes.com> wrote in message
news:B_OcnR1R6_4...@comcast.com...
Mark.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"M.S.Reddy" <msr...@indiatimes.com> wrote in message
news:B_OcnR1R6_4...@comcast.com...
You are probably right. Perhaps there is a better way. I have a many
servers/clients each talking to one other. Clients keep sending lot of data
(mostly images). all are single threaded. So, the obvious choice would be
making the sockets non blocking. But what can i do, if the receiver's socket
is not ready. I need to save the data and try again later. But there are
some packets that I have to send right away. So I want the socket to be
blocking so that it doesnt return until it sends it.I can do it by putting
send in a loop. The otheway is to make the sockets blocking and send the
unimportant data in non blocking manner. I wanted to do it in the second way
also wanted to learn how this can be acheived under windows.
I am not sure if my method is the best. Any suggestions are most welcome
There are several ways:
You can use the FD_XXXX macros with the select() function to test when data
is ready to be received.
You can also put your receive socket logic in a thread.
See the example at ftp://ftp.santronics.com/examples/socket/svrcli.zip
--
Hector Santos
Wildcat! Interactive Net Server
http://www.santronics.com
Eugene
"M.S.Reddy" <msr...@indiatimes.com> wrote in message
news:1-ednQkxMoi...@comcast.com...
As for sending important and unimportant data using different methodologies,
I would recommend using two client-side sockets. If you still want to
follow your model, you can set one to blocking, and one to non-blocking.
As other people have stated, probably the best way to approach this is to
use either IOCP or to use blocking mode sockets in combination with
WSAEventSelect(), WSAAsyncSelect() or select().
Is communication via TCP or UDP?
{L}
"M.S.Reddy" <msr...@indiatimes.com> wrote in message
news:JB2cnTm3fbl...@comcast.com...
You have some very bad misconceptions about the way TCP/IP works. I suggest you
read a good book or some web tutorials.
A blocking socket does not block until the data is sent, it blocks until the
data can be copied to an internal buffer while waiting to be sent. There is no
way for you to know that the receiver has received the data you sent without
adding that to your own protocol.
--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com
If this is exactly what you want to do, then make the socket non-blocking, and
write yourself a small "blocked_send" function. Don't just blindly loop on
send(), use select() so that you don't use up CPU time that would be better
spent elsewhere, and so that you can have a timeout (because the best-behaved
software needs to cope with a non-responsive receiver).
Note, finally, that your focussing on "the receiver's socket is not ready" is
a _bad_ thing. You have no way of knowing this. All you can know, and that's
what blocking is about, is whether you have buffer space in your sender.
After your send() is fully accepted, and until you get an acknowledgement from
the receiver application, you don't know (and don't need to know) whether the
data is in the send buffer, going across the network (in which case it's still
in the send buffer), at the receiver's network stack (in which case it may
still be in your send buffer), in the application but unprocessed (in which
case it is probably not in your send buffer, but might be, if the ACK hasn't
yet been received), or processed by the application (but you haven't received
the application's ACK).
When you send data, you have the following states:
1. I have data to send.
2. I have asked the stack to send it.
3. The application at the other end has told me that it received it.
All other states are illusory.
Alun.
~~~~
[Please don't email posters, if a Usenet response is appropriate.]
--
Texas Imperial Software | Try WFTPD, the Windows FTP Server. Find us at
1602 Harvest Moon Place | http://www.wftpd.com or email al...@texis.com
Cedar Park TX 78613-1419 | VISA/MC accepted. NT-based sites, be sure to
Fax/Voice +1(512)258-9858 | read details of WFTPD Pro for XP/2000/NT.