Socket Question ?

T

Tiraman

hi ,

i just started to work with sockets and there are 2 question that bother me.

1) i have a client server application and the server listen for incoming
connections from the clients BUT
how can i promise that nobody will kidnap my connections or will use his
own connections to that server ?

2) what is the deferent between the protocols (TCP,UDP) and protocol is the
most common in client application server ?

**************
*
Best Regards , *
*
Tiraman :) *
*
**************
 
N

Nak

Hi there,
1) i have a client server application and the server listen for incoming
connections from the clients BUT
how can i promise that nobody will kidnap my connections or will use his
own connections to that server ?

I'm not quite sure what you mean by this, but if you are thinking that
your "ports" might conflict with another application I wouldn't really worry
about it, start from port 1001and make a setting in your application for
changing this just incase you experience any conflicts. If you are thinking
people might spy on the data going between client and server then I
wouldsuggest using RSA encryption, create a set of keys for both client
*and* server and send the public key to the opposite end (i.e. client to
server, server to client). You can find out about RSA here,

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1648&lngWId=10
2) what is the deferent between the protocols (TCP,UDP) and protocol is the
most common in client application server ?

I like to think of UDP as "fire and forget", there is no guarantee or
fail safe mechanism for the data actually arriving at the other end! TCP is
very very clever and if data is not transmitted correctly it will invisibly
do it again! This is not to say that you cannot make a reliable UDP
application, I am currently using UDP for a debug server and it works
excellently without tying the application down to managing a TCP connection.

What is your application for? If you are doing file transfer I would
suggest using TCP. I hope this helps.

Nick.
 
T

Tiraman

Hi Nick,

first let me thank you for the response.

1) well, i asked if there is a way that some one with his own client will be
able to connect to my server and get the data as it was my client
(in case that he know the address and the port which is not so hard to
know :))?

2) About the ports issue, how can i find a free port (on the server and the
client) and how can i make my clients to
know this port each time since i have the port in some const in the
client and server?

3) how can i be sure that no one using my port, let say that you install my
client on your computer and there is another program that use this port?

4) i will check the RSA article, so Thanks.

5) my application is client-server which do few things like updating the
client about new articles (something like RSS Reader) and also you can talk
with
the people that are connected and few more things which relate to our
business.

6) if you need to do some server that need to broadcast data to all of the
connected clients would you use the UDP or TCP ?

7) what about performance deference between UDP and TCP ?

once again, Thanks for your help!
 
N

Nak

Hi there,
1) well, i asked if there is a way that some one with his own client will be
able to connect to my server and get the data as it was my client
(in case that he know the address and the port which is not so hard to
know :))?

You can't prevent this, it is *impossible*. People can always "port sniff"
to analyze a particular protocol. You can attempt to encrypt the data
between client and server using RSA encryption but that will not prevent
people decompiling your application.
2) About the ports issue, how can i find a free port (on the server and the
client) and how can i make my clients to
know this port each time since i have the port in some const in the
client and server?

Not many ports are in constant use, just use 1001, the liklihood of an
another application using that are very remote. Or the other way is to
upload a file to a web server each time the server is started and then have
the client download this file in order to locate the server.
3) how can i be sure that no one using my port, let say that you install my
client on your computer and there is another program that use this port?

Unlikely if you use port 1001, but if you are *really* that worried, you can
*pay* to have a port registered to your application, though who you go to
for this I have absolutly no idea!
4) i will check the RSA article, so Thanks.

Good idea ;-)
6) if you need to do some server that need to broadcast data to all of the
connected clients would you use the UDP or TCP ?

That is down for the server to do, I would use TCP for that as it requires a
solid connection and if the server needs to send packets to all *connected*
clients you should be using TCP.
7) what about performance deference between UDP and TCP ?

UDP is faster as it does not include fail safe measures and the like. But I
would not worry about performance being an issue because it is very unlikely
to cause your a problem. Just make sure that you make a "light weight" prot
ocol to maximize your bandwidth useage.
once again, Thanks for your help!

No probs! ;-)

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top