Jump to content
Sign in to follow this  
Triblade

Yet another chat program, but with bugs

Recommended Posts

Triblade

Yes, bugs :P

I've tried to make an client-server chat program with the possibility of multiple client logging in to the server.

What I don't have yet is the system to communicate back to the clients.

So it's a one way system right now.

I do have 2 problems which I cannot pinpoint. Perhaps I've been staring myself blind, so I'll hope some of you could point me in the right direction.

The 2 problems/bugs I am having are these:

1: My current maximum of clients to connect is set to 3, but the fourth can connect but isn't shown in the connection list in the server. It shoulden't be able to connect in my humble opinion.

2: This MsgBox line:

msgbox(0,"",$acceptedsocket[$track])oÝ÷ ØÌ'§µ«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì()±½°ÀÌØí½¹¹Ñͽ­Ðô´Ä°ÀÌØí͹Ð()U%
ÉÑ ÅÕ½Ðí
¡Ð
±¥¹ÐÅÕ½Ðì°ÐÌÀ°ÔÀÀ¤((ÀÌØíÑáѽàôU%
Ñɱ
ÉѥРÅÕ½Ðí]±½µÑ¼Ñ¡Õѽ%е
¡ÐÁɽɴ°
±¥¹Ð¥Ñ¥½¸ÌÌìÅÕ½ÐìµÀì
I1µÀì
I1°ÄÔ°ÄÀÀ°ÐÀÀ°ÄÔÀ°  ¥Ñ=È ÀÌØíM}I=91d°ÀÌØíM}UQ=YM
I=10¤¤((ÀÌØíÕÍɹµôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐíQÍÑÁÉͽ½¸ÅÕ½Ðì°ÄÔ°ÄÀ°ÄÀÀ°ÈÀ¤(ÀÌØí¥ÀôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÄÈܸÀ¸À¸ÄÅÕ½Ðì°ÄÔ°ÐÀ°ÄÀÀ°ÈÀ¤(ÀÌØíÁ½ÉÐôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìàÐÜÈÅÕ½Ðì°ÄÔ°ÜÀ°ÄÀÀ°ÈÀ¤(ÀÌØíÑáÐôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÄÔ°ÈØÀ°ÐÀÀ°ÈÀ¤((ÀÌØí͹ѸôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíM¹ÅÕ½Ðì°ÄÔ°ÈäÀ°ØÀ¤(ÀÌØí½¹¹ÑѸôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí
½¹¹ÐÅÕ½Ðì°àÀ°ÈäÀ°ÜÀ¤(ÀÌØí¥Í½¹¹ÑѸôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí¥Í½¹¹ÐÅÕ½Ðì°ÄÔÔ°ÈäÀ°ÜÀ¤()U%
ÑɱMÑMÑÑ ÀÌØí͹Ѹ°ÀÌØíU%}%M  1¤)U%
ÑɱMÑMÑÑ ÀÌØí¥Í½¹¹ÑѸ°ÀÌØíU%}%M  1¤()U%MÑMÑÑ¡M]}M!=¤()]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%M±Ð($%
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M($$%±½Í ¤($%
ÍÀÌØíµÍôÀÌØí½¹¹ÑѸ($$%Q
AMÑÉÑUÀ ¤($$$ÀÌØí½¹¹Ñͽ¬ôQ
A
½¹¹Ð¡U%
ÑɱI ÀÌØí¥À¤°U%
ÑɱI ÀÌØíÁ½ÉФ¤($$%%ÀÌØí½¹¹Ñͽ¬±ÐìÐì´ÄQ¡¸($$$%M±À ÄÀÀ¤($$$%͹ÑÀ ÅÕ½ÐíHÍÌÌíØÌÙ½¹¸ÅÕ½ÐìµÀìU%
ÑɱI ÀÌØíÕÍɹµ¤µÀìÅÕ½ÐíðÅÕ½ÐìµÀì%AÉÍÌĤ($$$%U%
ÑɱMÑMÑÑ ÀÌØí½¹¹ÑѸ°ÀÌØíU%}%M  1¤($$$%U%
ÑɱMÑMÑÑ ÀÌØí͹Ѹ°ÀÌØíU%}9   1¤($$$%U%
ÑɱMÑMÑÑ ÀÌØí¥Í½¹¹ÑѸ°ÀÌØíU%}9   1¤($$$%U%
ÑɱMÑMÑÑ ÀÌØíÕÍɹµ°ÀÌØíU%}%M    1¤($$$%U%
ÑɱMÑMÑÑ ÀÌØí¥À°ÀÌØíU%}%M  1¤($$$%U%
ÑɱMÑMÑÑ ÀÌØíÁ½ÉаÀÌØíU%}%M  1¤($$$%U%
ÑɱMÑÑ ÀÌØíÑáѽà°ÅÕ½Ðí
±¥¹Ð½¹¹Ñ¸ÅÕ½ÐìµÀì
I1°Ä¤($$$%µÍÍÌ ¤($$%±Í($$$%U%
ÑɱMÑÑ ÀÌØíÑáѽà°ÅÕ½Ðí$¸ÌäíÐʹѼ½¹¹Ð¸ÅÕ½ÐìµÀì
I1µÀìÅÕ½Ðí5åÑ¡ÍÉÙÈ¥¸ÌäíÐÉÕ¹¹¥¹°å½ÔÍ¡½Õ±ÑÉä¥É¹ÐÍÑÑ¥¹Ì¸ÅÕ½ÐìµÀì
I1µÀì
I1°Ä¤($$%¹%(%¹M±Ð)]¹()չ͹ÑÀ ÀÌØí͹¥¹¤(%Q
AM¹ ÀÌØí½¹¹Ñͽ¬°ÀÌØí͹¥¹¤)¹Õ¹()Õ¹±½Í ¤(%á¥Ð)¹Õ¹()Õ¹¥Í½¹¸ ¤(%U%
ÑɱMÑMÑÑ ÀÌØí½¹¹ÑѸ°ÀÌØíU%}9   1¤(%U%
ÑɱMÑMÑÑ ÀÌØí͹Ѹ°ÀÌØíU%}%M  1¤(%U%
ÑɱMÑMÑÑ ÀÌØí¥Í½¹¹ÑѸ°ÀÌØíU%}%M  1¤(%U%
ÑɱMÑMÑÑ ÀÌØíÕÍɹµ°ÀÌØíU%}9 1¤(%U%
ÑɱMÑMÑÑ ÀÌØí¥À°ÀÌØíU%}9   1¤(%U%
ÑɱMÑMÑÑ ÀÌØíÁ½ÉаÀÌØíU%}9   1¤(%͹ÑÀ ÅÕ½ÐíHÍÌÌíØÌ٥ͽ¹¸ÅÕ½ÐìµÀìÕ¥
ÑɱI ÀÌØíÕÍɹµ¤¤(%ͱÀ ÄÀÀ¤(%%ÀÌØí½¹¹Ñͽ­Ð±ÐìÐì´ÄQ¡¸Q
A
±½ÍM½­Ð ÀÌØí½¹¹Ñͽ­Ð¤(%Q
AM¡Õѽݸ ¤(%U%
ÑɱMÑÑ ÀÌØíÑáѽà°ÅÕ½Ðí
±¥¹Ð¥Í½¹¹Ñ¸ÅÕ½ÐìµÀì
I1°Ä¤)¹Õ¹()Õ¹µÍÍÌ ¤(%]¡¥±Ä($$ÀÌØíµÍôU%Ñ5Í ¤($%M±Ð($$%
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M($$$%¥Í½¹¸ ¤($$$%±½Í ¤($$%
ÍÀÌØíµÍôÀÌØí͹Ѹ($$$%͹ÑÀ¡U%
ÑɱI ÀÌØíÑáФ¤($$%
ÍÀÌØíµÍôÀÌØí½¹¹ÑѸ($$$%5Í    ½à ÄØ°ÅÕ½ÐíÉɽȽ¹¹Ñ¥¹ÅÕ½Ðì°ÅÕ½Ðí±±Éä½¹¹Ñ¸ÅÕ½Ðì¤($$%
ÍÀÌØíµÍôÀÌØí¥Í½¹¹ÑѸ($$$%¥Í½¹¸ ¤($$$%á¥Ñ1½½À($%¹M±Ð(%]¹)¹Õ¹

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
DarkShadow6

Heh... May be a 'lil late, but if your still doing this, I'll do it next Tuesdy. It has potential.

Share this post


Link to post
Share on other sites
DarkShadow6

I kno rite

lol

Anyway yeah, I looked over the script. I think I just may have to do something about that :3

Lol... I've only been on for 2 days and I've only had AutoIt for a week. i guess I just have the Magix Tuch lmao

Well I do like to script... ALot.... In VB and C and C++ and LUA etc

Share this post


Link to post
Share on other sites
DarkShadow6

$ip = GUICtrlCreateEdit("127.0.0.1", 80, 10, 100, 20, $ES_NOHIDESEL)

$ip = GUICtrlCreateEdit("127.0.0.1", 80, 10, 100, 20, ^ ERROR

What the heck?!

You included GUIConstants!

WTF?

Edit: Hah, you forgot to include EditConstants.au3

Edit 2: ROFL!!!!!! "I can't seem to connect. Maybe the server ain't running, you should try different settings."

Edit 3: Okay, I fixed the message box. But now, whenever more than one persoon connects a wierd error happens. But I did get the Set Max button working so it isn't balnked out all the time. I have an idea for the chat to show up on the clients... Basically if the server encounters chat and not an error or server-side-only message, it sends the chat to all the other clients. But I'm not sure how to go about doing that. Here's the code I have so far (and yes I edited it alot, removed some useless functions and kinda-sorta cleaned it up...):

*old code removed*

EDIT 4: ITS ALMOST DONE!!!!! I have even added commands for server admins. The commands are: Receive:disconn(username) (basically kick), Receive:admin(username), Receive:deadmin(username), Receive:message(text)!!!!!!!! Also, the client is all set up so that when one of the clients chats, its sent to the server and then sent to all the rest of the clients (currently broken, described below). When you stop the server, the server admin command disconn is sent to all clients (that was a prob before). The server admin can be decided with a button at the bottom of the server that says "give administratorship" (todo). Also you can now change the max ppl in a server that are allowed, and it actually works. All I have to do is get HateSandwich to bering his laptop tomorrow so we can test the interaction between two computers. If it works then hurrah.

Here's the only problem that I'm having:

This won't work...

ON THE SERVER:

CODE

Func sendToConnectedSockets($message)

For $track = 0 To $max - 1 Step 1

If $acceptedsocket[$track] <> -1 Then

TCPSend($acceptedsocket[$track], $message)

EndIf

Next

EndFunc

and on THE CLIENT

CODE

Func MainHandle()

...

...

$data = TCPRecv($connectsocket, 1024)

If $data <> "" Then checkCommand($data)

WEnd

EndFunc

Func checkCommand($messages)

Select

Case StringLeft($messages, 8) = "Receive:"

catchCommand(StringTrimLeft($messages, 8))

Case Else

If $messages <> "" Then

GUICtrlSetData($textbox, $messages & @CRLF, 1)

EndIf

EndSelect

EndFunc

Func catchCommand($received)

Select

Case StringLeft($received, 7) = "disconn"

Disconnect()

GUICtrlSetData($textbox, "The server administrator has disconnected you." & @CRLF, 1)

Case StringLeft($received, 7) = "admin"

$Admin = True

GUICtrlSetData($textbox, "The server administrator has given you control of the server." & @CRLF, 1)

Case StringLeft($received, 7) = "deadmin"

$Admin = False

GUICtrlSetData($textbox, "The server administrator has taken away your control of the server." & @CRLF, 1)

Case StringLeft($received, 7) = "message"

MsgBox(0, "", StringTrimLeft($received, 7))

EndSelect

EndFunc

I tested the commands and the rest of this code with an edit of the Client, and it all works. I'm just having an error where the Server won't "talk" to the client right. I even made the recieved come up ina message box, itt was blank. SO any way to figure out why it wont send it back to the client? The text goes to the server fine, but the server to client wont.

EDIT 5: I figured out why it glitched on 2 connections. I think its cuz only one connection per comp can be established with the server. :D

Edited by DarkShadow6

Share this post


Link to post
Share on other sites
Triblade

Yeah, im curious for the code now :D

Edit: Hah, you forgot to include EditConstants.au3

Heh, ur right :D

And you probably build it to the last AutoIt version instead of the 2007 version right? ;)

So, the old #include <GUIConstants.au3> is replaced by:

#include <GUIConstantsEx.au3> ; <-- Replaces GUIConstants.au3.

#include <WindowsConstants.au3> ; <-- this one is usefull for a lot of GUI stuff.


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
DarkShadow6

I still use GUIConstants.au3.

And yes I have the beta version of AutoIt.

You want the source so far? It's overall done.

Here's an outline of my progress:

Features:

Set up a chat room server on ANY computer and have an unlimited ammount of people join it.

The server control also has buttons: kick, admin, deadmin and send message to all.

Also, when you are an admin you can type Receive:kick(username) Receive:admin(username) Receive:deadmin(username) and Receive:message(text) just like the buttons! Also the server control has a list of peope in the server.

You can have a custom username.

To do:

Make some servers password protected.

Make a list of servers active (maybe store them in an INI file on a website? This one's a maybe).

Improvments:

Everyone is disconnected when the server is stopped.

The administrator system along with the buttons on the server control.

Problems:

The client program can send chat and commands to the server program, but when the server tries to send messages to all of the clients at once it doesn't send it correctly (it is prepared but just not sent).

It all works except for that stupid problem!

Help me please?

Edited by DarkShadow6

Share this post


Link to post
Share on other sites
DarkShadow6

Okay... In the last hour I've found out: I can't make heads or tails of the reason why the server won't talk to all the clients. You can fix it. Everything else is fine.

Server

*old code removed*

Client

*old code removed*

Edited by DarkShadow6

Share this post


Link to post
Share on other sites
Triblade

I don't have much time this day, but this ain't gonna work: StringLeft($received, 7) == "admin" :D Edit: well, it may work, but you dont want to gamble ;)

I will look at it soon.

Thanks, :D

Tri.

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
CodyBarrett

BTCP in my sig is a working multiclient chat.... also there are more in the examples section...

EDIT

maybe those will help you with what you want... ill look into your code in a half an hour or so

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
Triblade

Thanks.

I do know there are examples, but don't like to copy examples as I tend to copy them instead of learning. (not allways, but sometimes)

If someone points out a mistake I've made, I can't copy anything and I learn :D

Anyway, one error is that "Return $track" is supposed to be: "If $acceptedsocket[$track] = -1 Then Return $track"


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
DarkShadow6

Really? I thought wrong then.

Share this post


Link to post
Share on other sites
DarkShadow6

How do u liek my new GUI and commands? :?

Share this post


Link to post
Share on other sites
Triblade

Edit: Yeah looked nice. Even a title change.. Looks like it's gonna work soon :D

I made some improvements (in my humble opinion)

#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>


Global $recieve = "", $received, $listensocket = -1, $track = 0, $connected = 0, $connectionsocket = 0, $data, $empty, $max

GUICreate("DarkChat Server", 430, 500)

GUICtrlCreateLabel("IP Address:", 15, 15, 55, 20)
GUICtrlCreateLabel("Port:", 245, 15, 30, 20)
GUICtrlCreateLabel("Maximum allowed connections:", 15, 45, 150, 20)

$ip = GUICtrlCreateEdit("127.0.0.1", 72.5, 10, 160, 20, $ES_NOHIDESEL)
$port = GUICtrlCreateEdit("8472", 270, 10, 145, 20, $ES_NUMBER)
$maxConnections = GUICtrlCreateEdit("2", 165, 40, 50, 20, $ES_NUMBER)
$textbox = GUICtrlCreateEdit("Welcome to DarkChat Server Edition." & @CRLF & @CRLF, 15, 70, 400, 150, BitOr($ES_READONLY, $ES_AUTOVSCROLL, $ES_NOHIDESEL))
$setMax = GUICtrlCreateButton("Set maximum", 220, 40, 90, 20)
$startButton = GUICtrlCreateButton("Start Server", 15, 230, 65)
$stopButton = GUICtrlCreateButton("Stop Server", 80, 230, 65)
$kickButton = GUICtrlCreateButton("Kick User", 145, 230, 55)
$adminButton = GUICtrlCreateButton("Give Control", 200, 230, 65)
$deadminButton = GUICtrlCreateButton("Remove Control", 265, 230, 85)
$msgButton = GUICtrlCreateButton("Message", 350, 230, 67.5)
$userlist = GUICtrlCreateListView("#|User's screen name|User's IP address|User's socket ID", 15, 265, 400, 222.5, $ES_READONLY)
$currentMax = GUICtrlCreateLabel("", 325, 45, 150, 20)

GUICtrlSetState($stopButton, $GUI_DISABLE)
GUICtrlSetState($kickButton, $GUI_DISABLE)
GUICtrlSetState($adminButton, $GUI_DISABLE)
GUICtrlSetState($deadminButton, $GUI_DISABLE)
GUICtrlSetState($msgButton, $GUI_DISABLE)

GUISetState(@SW_SHOW)

Global $max = Int(GUICtrlRead($maxConnections)), $acceptedsocket[$max], $item[$max], $socketsLeft = $max ;; replaced setmaxglobal()
GUICtrlSetData($currentMax, "Currently set: " & $max) ;; dito

For $track = 0 To $max -1 Step 1
    $acceptedsocket[$track] = -1
Next

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Close()
        Case $msg = $startButton
            TCPStartUp()
            $listensocket = TCPListen(GUICtrlRead($ip), GUICtrlRead($port), 1)
            $connected = 1
            GUICtrlSetData($textbox, "Server started." & @CRLF, 1)
            GUICtrlSetState($stopButton, $GUI_ENABLE)
            GUICtrlSetState($kickButton, $GUI_ENABLE)
            GUICtrlSetState($adminButton, $GUI_ENABLE)
            GUICtrlSetState($deadminButton, $GUI_ENABLE)
            GUICtrlSetState($msgButton, $GUI_ENABLE)
            GUICtrlSetState($startButton, $GUI_DISABLE)
            GUICtrlSetState($setMax, $GUI_DISABLE)
            mainHandle()
        Case $msg = $stopButton
            MsgBox(16, "Error Disconnecting", "The server isn't connected.")
        Case $msg = $setMax
            setMaxGlobal()
    EndSelect
WEnd


Func Close()
    If $connected = 1 Then
        stopServer()
    EndIf
    Exit
EndFunc


Func stopServer()
    If $connected = 0 Then
        MsgBox(16, "Error", "The server is already being stopped.")
        Return False
    EndIf
    $connected = 0
    For $track = 0 To $max - 1 Step 1
    If $acceptedsocket[$track] <> -1 Then
        TCPCloseSocket($acceptedsocket[$track])
    EndIf
    Next
    TCPShutdown()
    GUICtrlSetData($textbox, "Server stopped." & @CRLF, 1)
    GUICtrlSetState($stopButton, $GUI_DISABLE)
    GUICtrlSetState($startButton, $GUI_ENABLE)
    GUICtrlSetState($setMax, $GUI_DISABLE)
    GUICtrlSetState($kickButton, $GUI_DISABLE)
    GUICtrlSetState($adminButton, $GUI_DISABLE)
    GUICtrlSetState($deadminButton, $GUI_DISABLE)
    GUICtrlSetState($msgButton, $GUI_DISABLE)
    For $i = 0 To $max Step 1
        _GUICtrlListView_DeleteItem($userlist, $i)
    Next
EndFunc


Func mainHandle()
    $empty = socketSearch() ;; added so this line won't loop when it's not needed, but it has to run once before going into the loop.
    
    While 1
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Close()
            Case $msg = $startButton
                MsgBox(16, "Error Connecting", "The server is already connected.")
            Case $msg = $stopButton
                stopServer()
                ExitLoop
            Case $msg = $kickButton
                $name = InputBox("Kick", "Enter someone's username here to kick them from the server.", "Username")
                sendToConnectedSockets("Receive:disconn" & $name)
            Case $msg = $adminButton
                $name = InputBox("Administrator Managment", "Enter someone's username here to give them administrative control over the server.", "Username")
                sendToConnectedSockets("Receive:admin" & $name)
            Case $msg = $deadminButton
                $name = InputBox("Administrator Managment", "Enter someone's username here to remove their administrative control over the server.", "Username")
                sendToConnectedSockets("Receive:deadmin" & $name)
            Case $msg = $msgButton
                $word = InputBox("Send Message", "Send a pop-up message to everyone on the server.", "Message")
                sendToConnectedSockets("Receive:message" & $word)
        EndSelect
        ;; removed $empty = socketSearch() because this line does not have to run every loop. I added up one and down one, read their comments
        If $socketsLeft > 0 then
            If $acceptedsocket[$empty] = -1 then
                $oldconnectionsocket = $connectionsocket
                $connectionsocket = TCPAccept($listensocket)
                If $connectionsocket = -1 Then
                    $connectionsocket = $oldconnectionsocket
                ElseIf $connectionsocket <> -1 Then ;; made elseif instead of twice an if
                    $acceptedsocket[$empty] = $connectionsocket ;; this line moved from the select cause because I wanted the socket to be changes as soon as possible
                    $socketsLeft = $socketsLeft - 1 ;; I moved this line from the select cause because I wanted the variable to be down one because if the client does not react, the loop does not know there is a connection in progress.
                    GUICtrlSetData($textbox, $socketsLeft & " sockets left.." & @CRLF, 1) ;; added for debugging
                    $empty = socketSearch() ;; added so only when a socket is gone, a new free one is sought
                EndIf
            EndIf
        EndIf
        
        $track = 0
        For $track = 0 To $max - 1 Step 1
            If $acceptedsocket[$track] <> -1 Then
                $data = TCPRecv($acceptedsocket[$track], 1024)
                If $data <> "" Then checkCommand($data)
            EndIf
        Next
    WEnd
EndFunc


Func checkCommand($messages)
    Select
        Case StringLeft($messages, 8) = "Receive:"
            catchCommand(StringTrimLeft($messages, 8))
        Case Else
            If $messages <> "" Then
                GUICtrlSetData($textbox, $messages & @CRLF, 1)
                sendToConnectedSockets($messages)
            EndIf
    EndSelect
EndFunc

Func socketSearch()
    Local $track = 0
    
    For $track = 0 To $max - 1 Step 1
        If $acceptedsocket[$track] = -1 Then Return $track ;; added if, else it allways returns...
    Next
EndFunc

Func catchCommand($received)
    Local $found, $item ;; added $item just because I can :) 
    
    Select
        Case StringLeft($received, 4) = "conn"
            ;; removed two lines and put then at line 138 & 139. Read those comments.
            $found = _ArraySearch($acceptedsocket, $connectionsocket) ;; needed for the array number which we need at disconnect to set arrayitem to -1
            GUICtrlSetData($textbox, StringTrimLeft($received, 4) & " has connected." & @CRLF, 1)
            GUICtrlCreateListViewItem($found & "|" & StringTrimLeft($received, 4) & "|" & $connectionsocket, $userlist) ; added the first column in front instead of the $empty variable that is easely flawed when code changes
            sendToConnectedSockets(StringTrimLeft($received, 4) & " has connected." & @CRLF)
        Case StringLeft($received, 7) = "disconn"
            $socketsLeft = $socketsLeft + 1
            GUICtrlSetData($textbox, StringTrimLeft($received, 7) & " has disconnected." & @CRLF, 1)
            sendToConnectedSockets(StringTrimLeft($received, 7) & " has disconnected." & @CRLF)
            $socketTemporary = StringTrimLeft($received, 7)
            $found = _GUICtrlListView_FindInText($userlist, StringTrimLeft($received, 7))
            $item = _GUICtrlListView_GetItemTextArray($userlist, $found)
            TCPCloseSocket($item[4]) ;; 3 = 4 cause one column is added
            $acceptedsocket[$item[1]] = -1 ; first column
            _GUICtrlListView_DeleteItem($userlist, $found)
            $empty = socketSearch() ; we have free sockets! yay!
    EndSelect
EndFunc

Func setMaxGlobal()
    $max = Int(GUICtrlRead($maxConnections))
    Redim $acceptedsocket[$max], $item[$max] ;; ReDimm is needed to adjust array size for future expansion
    $socketsLeft = $max
    GUICtrlSetData($currentMax, "Currently set: " & $max)
EndFunc

Func sendToConnectedSockets($message)
    For $track = 0 To $max - 1 Step 1
        If $acceptedsocket[$track] <> -1 Then
            TCPSend($acceptedsocket[$track], $message)
        EndIf
    Next
EndFuncoÝ÷ ØƲm쨻§¶Ú-)äiº.µ§]xæz¸§¶©®+jkh²0Ýý±«­¢»ºÚ"µÍØÜÈKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKB]]Ò]Ú[ÛËË
]JB]]Ü^S[YBØÜ[Ý[ÛU[]H]]Ò]ØÜØÙHKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKBÈØÜÝHY[ÝÛÙH[ÝÈ
Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
Triblade

Why the client does not receive anything from the server:

It has no good connection with it.

In the client:

Search & Replace all: $connectsock with: $connectsocket

Edit: typo :D

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
DarkShadow6

Argh I edited it a lot, but no good. I found out the connectsock a while ago. Its making me mad, almost like shoving goatse in my face > :D

Edited by DarkShadow6

Share this post


Link to post
Share on other sites
DarkShadow6

I think I have fixed something!

I changed...

$listensocket = TCPListen(GUICtrlRead($ip), GUICtrlRead($port), 1)

...to...

$listensocket = TCPListen(GUICtrlRead($ip), GUICtrlRead($port), GUICtrlRead($maxConnections))

IDK but anyway.. Here's the source so far. Check it out. I still can't get it to connect.

EDIT: IDK, maybe I farked it up.

*old source removed*

Edited by DarkShadow6

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  

×