Sockets

A

Adam Honek

Hello,

Can someone pinpoint me to a reliable link relating to sockets
and how they are implemented to allow client/server communication?

I'm finding quite a few but very few actually explain it step by step and
a lot of the source code examples I see is not commented or commented
poorly.

P.S Is Sockets and TCPClient the same thing?

Many thanks,
Adam Honek
 
D

DevNick

I dont have time to go into super deep detail atm but here goes.

The server has to pick a local port.. say port 80.
You create the socket and then set it to listening mode.

On the client you create a socket with a local port(this will use any
available client port automatically by telling the socket to do so). So you
do NOT have to or really should you assign a specific client socket port to
the client socket.

When the client connects to the server, the server responds on the LISTENING
socket. If its a program that continues to allow connections, then what you
do is create another socket on the server, and then HAND the connection to
that socket so that the client is no longer communicating to the listening
socket, say on port 80, but another socket on the server.

I hope that at least helps inthe step by step "typology" of how it works.
now you just need to implement it.

Thats alot more then I have time to explain atm, but you should use the
sockets connection method to create the new socket(or clone) and use the new
socket to talk to the client request. this way your not tieing up the main
listener.

Make sense?
 
A

Adam Honek

Yes thanks for that.

So you're basically saying the client(s) send to a server (a program running
somewhere on the current PC or out there somewhere) and it responds
by sending back the client(s) text to each connected client.

In other words the server is acting as a gateway.

The thing that confusing me is the TCPClient() approach and the Socket()
approach, are these the same thing because they don't appear to be.

Thanks,
Adam H.
 
D

DevNick

To be honest I have no idea what you mean by "tcpclient" versus socket.
a TCPClient is merely a client that uses a TCP specific type of socket
instead of a UDP or other type.
You specify the socket type when you create it, such at FTP is TCP, Telnet
is TCP, HTTP is TCP.. so I dont get what your asking or am confused about?
Can you explain a little more detail please.

A socket can transfer anything you want over, the only limitations are the
bus, buffer and speed. A UDP or TCP socket can transfer the EXACT same
content, text, binary data, a stream etc.

Thanks
 

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