Re: CSocket : testing (easy ... RE: AliR)
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/10/05
- Next message: Polaris: "API: Laptop or Desktop ?"
- Previous message: Christopher J. Holland.........................................................: "Terminating threads in Destructor"
- In reply to: Juha-Pekka Kettunen: "CSocket : testing (easy ... RE: AliR)"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 09 Feb 2005 19:54:09 -0500
First, avoid CSocket entirely. This is always a mistake. Use CAsyncSocket exclusively.
While testing on your machine validates your protocol, it does not validate that your
protocol will work between two arbitrary machines.
First, you must not be using UDP. UDP is usually blocked at firewalls, and any router
between any two arbitrary machines is free to drop any UDP packet at any time for any
reason, and never, ever does it have to tell you that this happened. A UDP packet may be
truncated at any router to the minimum mandated by the Internet standards, and you will
never know; but since loopback doesn't involve a router it does not necessarily have to
truncate. UDP on loopback is utterly reliable; UDP across the Internet is asking for
trouble. Big time.
If you use TCP/IP, the number of problems that synchronous CSocket will get you into are
simply not worth dealing with.
Port numbers can be blocked at various routers for security reasons; for example, my
incoming router blocks ALL incoming TCP/IP and UDP port connections, allowing only
connections initiated by my machine to go outwards and get responses.
You should also make provision for the end user to reassign the port numbers used for
communication, since there is always the potential for conflict with a registered port
number for a service.
So any given point-to-point communication might fail due to routers and firewalls.
However, once you establish a TCP/IP connection, you know that you have a solid connection
and if anything goes wrong you will get a notification.
The reason for CAsyncSocket is that if the remote program hangs, your program hangs also,
and cannot be cleanly shut down. which is one of the major reasons for using CAsyncSocket.
joe
On Tue, 08 Feb 2005 21:20:36 GMT, "Juha-Pekka Kettunen"
<POISTA_AUTO_juhafiatkettunen@hotmail.com.invalid> wrote:
>ok, I got this chatter prog work.
>
>One question about debugging and testing: If I run these progs
>(client/server) *both on my own pc* to test them, Is it exactly the same
>thing than if I tested them with another pc though *internet*? So, does the
>messages go through the internet and come back to my computer? So if client
>and server works on my computer is it guaranteed to work with other
>computers as well though the internet?
>
>Juha
>
>
>
>>Here is an example from microsoft on how to write socket programs
>>
>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_CHATTER.asp
>
>>AliR.
>
>"Juha-Pekka Kettunen" <POISTA_AUTO_juhafiatkettunen@hotmail.com.invalid>
>wrote in message news:9RNNd.1711$K_6.457@newsfe1-win.ntli.net...
>> Hi
>>
>> I have never done this so I would like to ask that how do I communicate
>with
>> another pc on the Internet. For example if I want to send a message "Hello
>> World" from Finland to England though the Internet. I am using MFC. Is it
>> CAsyncSocket? Can you give me an example how to do it? thanks. I have not
>> done much internet programming, so I am a newbie ...
>>
>> The thing is that I want to make a multiplay game (server/client system)
>on
>> the internet and need to send some data ...
>>
>>
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Polaris: "API: Laptop or Desktop ?"
- Previous message: Christopher J. Holland.........................................................: "Terminating threads in Destructor"
- In reply to: Juha-Pekka Kettunen: "CSocket : testing (easy ... RE: AliR)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|