Sign in to follow this  
Followers 0
Ghastly_MIB

Connect TCP

5 posts in this topic

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

Share this post


Link to post
Share on other sites



The new beta supports sockets.

Usually you can connect several clients to a listening (server) socket...

Share this post


Link to post
Share on other sites

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..
;)

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by MrSpacely

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0