Rad Posted August 18, 2006 Share Posted August 18, 2006 (edited) http://www.autoitscript.com/forum/index.ph...mp;#entry222573I didnt even know you could do that with autoit!! i was messing around with it trying to make my own (to learn how it works better) and was trying to send to an edit on the server, but it only worked for the first message... I really dont understand the way he coded it above, with chr()'s and all the variables Could someone explain how to better use the TCP Recv and TCP Send a little bit better? Its not working and I just dont understand why... Heres what I have now, just run this and the Client in your au3\beta\helpfile folder... It doesnt really work though.... id really like to get this to workEDIT: This works a little bit better, except it doesnt recieve the first character (the client accepted: 1/2 is for testing)expandcollapse popup#Include <GUIConstants.au3> Dim $IPAddress Dim $Port Dim $Users[8] Dim $UserView[8] Dim $RecieveMsg $UserSlots = "12345678" $Temp = InputBox("Server","Enter your IP",@IPAddress1,"",200,128) If Not @error Then $IPAddress = $Temp Else Exit Endif $Temp = InputBox("Server","Enter a port (0-65535)","2048","",200,128) If Not @error Then $Port = $Temp Else Exit Endif TCPStartup() $Listen = TCPListen($IPAddress, $Port, 8) $Window = GUICreate("Server",384,256) $Edit = GUICtrlCreateEdit("",2,2,380,252) ;~ $ListView = GUICtrlCreateListView(" Username | IP Address | Socket ",2,2,254,252,BitOr($LVS_SHOWSELALWAYS,$LVS_NOSORTHEADER)) ;~ For $i = 0 to 7 ;~ $UserView[$i] = GUICtrlCreateListViewItem("Empty|192.168.101.10" & $i & "|Null",$listView) ;~ Next GUISetState() If $Listen = -1 Then Msgbox(0,"Error","Invalid IP or Port!") Exit Endif $temp = $Users[StringLeft($UserSlots,1)] While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If StringLen($UserSlots) > 0 Then $Users[StringLeft($UserSlots,1)] = TCPAccept($Listen) If $temp <> $Users[StringLeft($UserSlots,1)] Then msgbox(0,"Client Accepted","Accepted Client: " & StringLeft($UserSlots,1)) $temp = $Users[StringLeft($UserSlots,1)] Else $Temp = TCPAccept($Listen) TCPSend($Temp,"Server is full") TCPCloseSocket($Temp) Endif If $Users[StringMid($UserSlots,1,1)] >= 0 Then msgbox(0,"","Client Connected") If StringLen($UserSlots) <> 0 Then $UserSlots = StringMid($UserSlots,2,StringLen($UserSlots)) Else $UserSlots = "" Endif EndIf If TCPRecv($Users[1],1) <> "" Then msgbox(0,"",TCPRecv($Users[1],1000)) ;~ For $i = 0 to 7 ;~ If StringInStr($UserSlots,$i) = 0 Then ;~ $Temp = TCPRecv($Users[$i],1) ;~ If $Temp <> "" Then ;~ msgbox(0,"",$temp) ;~ $RecieveMsg = $RecieveMsg & $Temp ;~ GUICtrlSetData($Edit,$RecieveMsg) ;~ Endif ;~ Endif ;~ Next Wend Edited August 18, 2006 by Rad Link to comment Share on other sites More sharing options...
themax90 Posted August 18, 2006 Share Posted August 18, 2006 I have a thread about TCP. Check my signature for many examples. Specifically TCP Internal Server Update 1 which allows you to customize the Stream and Funciton prefixes. (Aka Chr(X)) Link to comment Share on other sites More sharing options...
Rad Posted August 18, 2006 Author Share Posted August 18, 2006 (edited) For EVERYTHING and ALL THINGS TCP RELATED, Don't Post! Go Here :http://www.autoitscript.com/forum/index.ph...c=20589&hl= Edited August 18, 2006 by Rad Link to comment Share on other sites More sharing options...
themax90 Posted August 18, 2006 Share Posted August 18, 2006 Why cry? Link to comment Share on other sites More sharing options...
Rad Posted August 18, 2006 Author Share Posted August 18, 2006 I dont really get this lolhttp://www.autoitscript.com/forum/index.ph...c=18738&hl=Do I use this as an include? and if I do... whats different? I mean ... TCPRecieve looks like TCPRecvPlus, you made it easy but you didnt explain it to newbie status Link to comment Share on other sites More sharing options...
themax90 Posted August 18, 2006 Share Posted August 18, 2006 No it is TCP Made Easy because it explains it in a scripters mind. Set's errors and returns values according to the actual function. That way you can understand it more instead of using the helpfile. The only function I recommend is TCPStartServer 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