Ghastly_MIB Posted September 8, 2005 Share Posted September 8, 2005 Hey all, i'm trying to make a messenger for the netwerk with TCP. Is it posible to connect multiple clients to one server? If it can, how? Thanks, Ghastly_MIB Link to comment Share on other sites More sharing options...
andd Posted September 8, 2005 Share Posted September 8, 2005 The new beta supports sockets. Usually you can connect several clients to a listening (server) socket... Link to comment Share on other sites More sharing options...
Ghastly_MIB Posted September 8, 2005 Author Share Posted September 8, 2005 So I coult use this?: $g_IP = "192.168.0.2" $MainSocket = TCPListen($g_IP, 65432, 100 ) $g_IP = "192.168.0.3" $MainSocket2 = TCPListen($g_IP, 65432, 100 ) Enz.. Link to comment Share on other sites More sharing options...
andd Posted September 8, 2005 Share Posted September 8, 2005 So I coult use this?:$g_IP = "192.168.0.2" $MainSocket = TCPListen($g_IP, 65432, 100 ) $g_IP = "192.168.0.3" $MainSocket2 = TCPListen($g_IP, 65432, 100 ) Enz.. <{POST_SNAPBACK}>You just need one listening socket, which is the server. Then the clients can connect to this socket.With TCPAccept you can define which action should be done when a client connects.Check the the example in the help file, it also deals with a chat program... Link to comment Share on other sites More sharing options...
MrSpacely Posted September 8, 2005 Share Posted September 8, 2005 (edited) You can accept using an array. There is a script somewhere on the forum wich shows this, its created by larry and its a chat client/server and it works. It uses socket variable in a array wich makes it possible to have multiple sockets at once. Only larrys script was for a broadcast like chat wich sends text to all users. You need to have more arrays to be able to send to specific users. An array per connection is needed I think a multi dimension array even because you to save the text per conversation per user (like a buffer per conversation per user) for $concounter=1 to $totalcon $connection[$concounter] for $conversationcounter=1 to $maxconversations[$concounter] senddata($concounter, $condata[$concounter][$conversationcounter] [1],$condata[$concounter][$conversationcounter][2]) next next for example sending the array $condata[connection][connection you chatting with][flag] flag being 1 contains connection identifier flag being 2 contains chat data you need to send to that connection try looking for chat made by larry for multi socket hints Edited September 8, 2005 by MrSpacely Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now