GreenBox Posted February 4, 2009 Share Posted February 4, 2009 (edited) This code will work fine in ansi. But, i run unicode, it is well error. it well be not work. #AutoIt3Wrapper_UseAnsi=n TCPStartup() Local $Chk = _TCPChack("안녕하세요? 이것은 테스트입니다." & @CRLF & "TEST 01234567890123456789") MsgBox(64, "Send Message", $Chk[0][0]) MsgBox(64, "Recv Message", $Chk[1][0]) If $Chk[0][1] = $Chk[1][1] Then Local $Ck = 64 Else Local $Ck = 16 EndIf MsgBox($Ck, "TCP Chack", "Send Message Len :" & $Chk[0][1] & @CRLF & "Recv Message Len :" & $Chk[1][1]) TCPShutdown() Func _TCPChack($msg, $port = 1024) Local $Ssock = TCPListen("127.0.0.1", $port) Local $Csock = TCPConnect("127.0.0.1", $port) Local $Asock = TCPAccept($Ssock) Local $Sendmsg = $msg TCPSend($Csock, $Sendmsg) Local $Recvmsg = TCPRecv($Asock, 1024) Local $Rtable[2][2] $Rtable[0][0] = $Sendmsg $Rtable[1][0] = $Recvmsg $Rtable[0][1] = StringLen($Sendmsg) $Rtable[1][1] = StringLen($Recvmsg) TCPCloseSocket($Ssock) TCPCloseSocket($Csock) TCPCloseSocket($Asock) Return $Rtable EndFunc ..; Edited February 4, 2009 by GreenBox Link to comment Share on other sites More sharing options...
BrettF Posted February 4, 2009 Share Posted February 4, 2009 Hi, Try sending as binary, then converting the string back... Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
GreenBox Posted February 4, 2009 Author Share Posted February 4, 2009 Hi,Try sending as binary, then converting the string back... Cheers,BrettBut i only can 'TCPSend", not 'TCPRecv'..; Link to comment Share on other sites More sharing options...
BrettF Posted February 4, 2009 Share Posted February 4, 2009 Try TCPSent (ChrW (1234) & ChrW (3455)....) for sending the strings. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
GreenBox Posted February 4, 2009 Author Share Posted February 4, 2009 Try TCPSent (ChrW (1234) & ChrW (3455)....) for sending the strings. Cheers, Brett i can't it. it is too hard. expandcollapse popup#AutoIt3Wrapper_UseAnsi=n $String = "안녕하세요? 이것은 테스트입니다." & @CRLF & "TEST 01234567890123456789" $Str = "" For $i = 1 to StringLen($String) $Str &= AscW(StringMid($String, $i, 1)) & '|' Next TCPStartup() Local $Chk = _TCPChack($Str) MsgBox(64, "Send Message", $Chk[0][0]) MsgBox(64, "Recv Message", $Chk[1][0]) If $Chk[0][1] = $Chk[1][1] Then Local $Ck = 64 Else Local $Ck = 16 EndIf MsgBox($Ck, "TCP Chack", "Send Message Len :" & $Chk[0][1] & @CRLF & "Recv Message Len :" & $Chk[1][1]) TCPShutdown() Func _TCPChack($msg, $port = 1024) Local $Ssock = TCPListen("127.0.0.1", $port) Local $Csock = TCPConnect("127.0.0.1", $port) Local $Asock = TCPAccept($Ssock) Local $Str = StringSplit($msg, "|") Local $Sendmsg, $i For $i = 1 to $Str[0] $Sendmsg &= ChrW($Str[$i]) TCPSend($Csock, ChrW($Str[$i])) Next Local $Recvmsg = BinaryToString(TCPRecv($Asock, 1024)) Local $Rtable[2][2] $Rtable[0][0] = $Sendmsg $Rtable[1][0] = $Recvmsg $Rtable[0][1] = StringLen($Sendmsg) $Rtable[1][1] = StringLen($Recvmsg) TCPCloseSocket($Ssock) TCPCloseSocket($Csock) TCPCloseSocket($Asock) Return $Rtable EndFunc if i recv it, recv msg broken... 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