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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nonBlocking Sockets - TTcpServer

Status
Not open for further replies.

thodoris

Programmer
Jun 24, 2003
1
0
0
GR
Hi,
i am trying to make a simple server/client application using the TTcpServer, TTcpClient components. I want to use them both in non-blocking mode (I do not want to use threads), however I cannot make them work. I get (at the client) a socket error when it tries to connect (error code 10035). On the server side no event is fired at all (not even the OnListening one).
Could you please help me (any tutorial, tip, sample source...whatever would be helpful.)
Thanks a lot...
 
Hi, do us a favour mate and post your code, or email it me cos theres a whole load of things that could be up with it..... I've done quite a bit with teh client / server sockets so i might be able to help.... also on another note you still got your threading code? i'll take a look at that aswell if you want, and have a go at making it work.

hope i can be some help.
Cheers
 
Thodoris:

It is relatively simple although you don't explain if you are using the two programs on one machine or different machines.

To get it working write two simple programs, on with client socket, the other with the server socket. Make the client socket non-blocking, active false. Put a button on the menu and an OnClick event that does socket1.active := true; Put an OnConnect in the Server program with a showmessage('Connected!'); and set active to true. Hard set the IP addresses to 127.0.0.1 and port ???? (I use 1280). Start them up, click the button and you should see the 'Connected!' message.

HTH
JGS
 
jgslater9:
Your 'code' doesn´t work.
First of all: TTcpServer doesn´t have an OnConnect event. I used OnAccept instead.
Second: TTcpServer must be listening to possible conections. You can do it with WaitForConnection or Accept
 
schumacker:

Perhaps I should have been more specific. The "server socket" I referenced is a TServerSocket component which indeed has an OnClientConnect event. Pardon the lack of words.

JGS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top