Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Socket Connection And Multithreading

Status
Not open for further replies.

sabelo

Programmer
Apr 7, 2003
9
NZ
I am kind of new to socket programming, though I know the basics. I am doing a project on client/server application. 1. how does MSN/yahoo messenger connect coz they can connect across firewalls with no problem. 2. When doing a two way communication do I need to have a server and client on each side? If that's the case then how would the client on the other side know the host name of the initiator? Does the initiator have to send their IP address? 3. Does anyone have an idea how to implement multithreading in Delphi 5, I have the Indy components.

Your help will be highly appreciated.
 
1. Both MSN and Yahoo maintain a server as intermediary for the clients.

Neither always goes through a firewall. They are reasonably easy to block, although they are slippery. Usually the complaint from people with firewalls is that these messengers no longer work at all.

2. Do you need a server and client on both sides? The two messenger services you used as examples implicitly demand a server role from the client. One of the easiest ways to block them, for example, is to deny them in-bound access to the service side ports required of the client. Similarly FTP and other programs essentially create a server role of the client. The remote side sends to the service side of the client, the remote side is, relative to the client, in a comparitvely passive service role during the exchange.

3. Can't help you with Delphi, sorry.
 
Hi Sabelo!!!

When a client machine connects to a socket on a server, you are establishing a bidirectional communication between the machines, so you need only 1 server and 1 client...

The establishment of the connection between the machines requires several steps that are reflected on events, for the ones you can write your own handlers, for example this happens when a server will accept a connection from a client, this is the first time you have access to the client's information (ip, port, etc)...

For the server you can use TServerSocket and for the client TClientSocket (both are VCL components)...

If you are thinking about using threads, but you want to mix them with sockets stuff, then stop thinking about them like separated things, because you can use the socket in non-blocking mode, which means everytime a new requests arrives to the server, the socket spawns a new thread for that request, this makes life really easier...

I used them on a project in C++Builder, but Delphi is VCLized to so I think is the same...

This is a general idea, want something more detailed? just post a message

CU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top