dromenox Posted July 15, 2014 Share Posted July 15, 2014 (edited) I'm creating a TCP server and I have a problem. At the same time a client connects it disconnects now. If someone can tell me where is the problem! expandcollapse popup#include <Array.au3> #include "functions.au3" TCPStartup() global $Clients[0][2] global $OnlineUsers global $Listen $Listen = TCPListen(@IPAddress1, 50000, 20) while 1 Clean() Proccess() Accept() wend func Clean() local $i for $i = UBound($Clients) - 1 to 0 step -1 TCPSend($Clients[$i][0], 'test') if @error then TrayTip('SERVER', 'DISCONNECTED CLIENT', 5) TCPCloseSocket($Clients[$i][0]) _ArrayDelete($Clients, $i) endif next endfunc func Proccess() local $i for $i = UBound($Clients) - 1 to 0 step -1 local $Recv = TCPRecv($Clients[$i][0], 256) if $Recv then if StringSplit($Recv, ';')[1] = 'login' then if correctInfo(StringSplit($Recv, ';')[2], StringSplit($Recv, ';')[3]) then if not isOnline(StringSplit($Recv, ';')[2], $OnlineUsers) then TCPSend($Clients[$i][0], 'success') $Clients[$i][1] = StringSplit($Recv, ';')[2] else TCPSend($Clients[$i][0], 'already_online') endif else TCPSend($Clients[$i][0], 'wrong_info') endif elseif StringSplit($Recv, ';')[1] = 'register' then if not userExists(StringSplit($Recv, ';')[2]) then regUser(StringSplit($Recv, ';')[2], StringSplit($Recv, ';')[3]) TCPSend($Clients[$i][0], 'success') else TCPSend($Clients[$i][0], 'user_exists') endif endif MsgBox(0, 'SERVER', $Clients[$i][1] & ' send ' & $recv) endif next endfunc func Accept() local $Socket = TCPAccept($Listen) if $Socket <> -1 then TrayTip('SERVER', 'NEW CLIENT', 5) _ArrayAdd($Clients, 0) redim $Clients[UBound($Clients) + 1][2] $Clients[UBound($Clients) - 1][0] = $Socket $Clients[UBound($Clients) - 1][1] = 'null' endif endfunc Edited July 15, 2014 by dromenox Link to comment Share on other sites More sharing options...
JScript Posted July 15, 2014 Share Posted July 15, 2014 Hi, read this: http://www.autoitscript.com/autoit3/devs/jpm/%232384_UDPTCP_@error/UDPTCP%20change%20@error.txt JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
dromenox Posted July 15, 2014 Author Share Posted July 15, 2014 And TCPSend ? Link to comment Share on other sites More sharing options...
JScript Posted July 15, 2014 Share Posted July 15, 2014 I had this same problem and believe: TCPSend has nothing to do! Read this: '?do=embed' frameborder='0' data-embedContent>> JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
dromenox Posted July 15, 2014 Author Share Posted July 15, 2014 Thanks ! I will read ! Valeu !!! Link to comment Share on other sites More sharing options...
Luigi Posted July 15, 2014 Share Posted July 15, 2014 I like "Valeu"! dromenox 1 Visit my repository 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