Link to home
Start Free TrialLog in
Avatar of trolliits
trolliits

asked on

VB.NET Multiple client/server application

Hi, I'm creating a very simple game that could be played online. A server would need to accept and send text data and client would need to receive data from and send to the server.

Basically something like this:
Client connects to the server and sends text message: CREATE_ROOM{user=test&roomname=test}

Server then says let's say SUCCESS{cmd=create_room&room_id=1&session=whatevermd5stringhere}

I have no idea how to make this work because everything I tried so far just did not work. Please help guys.

PS. There should be an option to send a command to all clients.

For example when one client creates a room and server accepts it, it should send a message to all clients eg: MULTIMSG{cmd=addroom&creator=usernamehere&session=whatevermd5stringhere}.
The client will interpret that message and add a room into the listbox.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

That's a tall order.  Can you show us your code?
Was there a question in there?
This question sound like "somebody please help me to develop my full application". This approach won't work here at EE.
My suggestion is: try to do it by yourself as much as possible. Whenever you find a blocker, post a new specific question and supporting source code. That will give you better results.
Avatar of trolliits
trolliits

ASKER

I used this source code and tried to make it work like I need, but couldn't.

http://code.msdn.microsoft.com/Simple-Multi-User-TCPIP-43cc3b44?SRC=VSIDE
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not really, I don't know much about socket programming.
I took a close look at the code and I could probably make everything work except sending data to all clients part.
Change the SendMessage() method in ConnectionInfo() from Private to Public.  Now you can use code like this:
Public Class ServerForm

    Private _Connections As New List(Of ConnectionInfo)

    Public Sub SendMessageToAll(ByVal msg As String)
        For Each connection As ConnectionInfo In _Connections
            connection.SendMessage(msg)
        Next
    End Sub

End Class

Open in new window