News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Network programming

Started by Grincheux, March 17, 2011, 06:15:06 AM

Previous topic - Next topic

Tedd

Quote from: Grincheux on March 26, 2011, 05:06:02 PM
Now, i am thinking about sending and receiving datas. I would like to use a thread for sending and an other for receiving. I want to do like this because, I could get two users that transmit nearly at the same time. If the receiving function is not stored into a thread I can't get the second ?
You will receive FD_READ each time a user sends something, with wParam indicating the particular socket to read this data from (and thus who sent it.) You can then deal with that and return. And then you'll receive more notifications for other incoming data on other sockets. There isn't really a problem with multiple incoming connections, unless you're streaming lots of data and need low latency.

Quote
One thing, I am thinking about is how to check that a connection is lost. Do I have to create a timer for sending dummy datas to each connected user ? Do I have to wait that I receive from or I have to send to ?
You receive FD_CLOSE when a client closes the connection or the connection is lost. You don't need to do anything special (except add it to the mask in WSAAsyncSelect.) When the connection is closed, there is no remaining incoming data to receive.
No snowflake in an avalanche feels responsible.

oex

Quote from: Tedd on March 26, 2011, 10:48:38 PM
oex, I'm afraid you're only confusing things further ::) You should read this too.

Ah sorry, it's a very long time since I wrote any server code :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Grincheux

Thank you Tedd, a very good course.

FOr incoming connections now that's ok.

I want to test if the station already is connected, for the following reason. My job, is to repair phone lines. I repair when a tree is falling to the line cable, or when there are too many errors on the customer's line. When there is a lot of wind, the datas can be lost and the link between the router and the head of the line can have a poor quality. There are many technical reasons than make me think that the connection can be lost without receiving a FD_CLOSE event.

Some lines I have to repair have a lot of CRC errors (I use a MC2+ for testing lines) and other erros such as FEC, HEC...

I can also find capacitors that will drop the frequency of ADSL and lead a power connection.

Here are the reasons for which I wanted to send dummy datas between the server and the station.

What do you think about
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Grincheux

Here is a pdf file giving informations about the MC2+ used for my job. The problems I meet during repairing ADSL user's problems, I want to include them into my programs and it seems to be a good idea for me.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Tedd

Quote from: Grincheux on March 27, 2011, 06:48:57 AM
I want to test if the station already is connected, for the following reason. My job, is to repair phone lines. I repair when a tree is falling to the line cable, or when there are too many errors on the customer's line. When there is a lot of wind, the datas can be lost and the link between the router and the head of the line can have a poor quality. There are many technical reasons than make me think that the connection can be lost without receiving a FD_CLOSE event.

Some lines I have to repair have a lot of CRC errors (I use a MC2+ for testing lines) and other erros such as FEC, HEC...

I can also find capacitors that will drop the frequency of ADSL and lead a power connection.

Here are the reasons for which I wanted to send dummy datas between the server and the station.

What do you think about
For stream-based sockets (TCP), this isn't an issue. The connection is frequently checked for connectivity by sending small packets of data - this is all done automatically, you don't need to do anything. If the connection is lost, this will be detected and you will still receive FD_CLOSE after some time-out period with no reply. Transmission errors are also checked - any packets with an incorrect checksum are re-sent (automatically.)

For datagram sockets (UDP), you don't have this support, so you must do almost everything yourself.
No snowflake in an avalanche feels responsible.

Grincheux

I am happy you are there. All my questions have found a very good answer. Thank you. I did not think that FD_CLOSE was running like this. Now the post can be closed.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz