RexRomae Posted June 11, 2008 Share Posted June 11, 2008 I have this code compiled in client.exe and this in server.exe ... Avast Antivirus indicates they like virus trojan/worm.. why??!! expandcollapse popup;CLIENT! Start Me after starting the SERVER!!!!!!!!!!!!!!! ; see TCPRecv example #include <GUIConstants.au3> ; Start The TCP Services ;============================================== TCPStartUp() ; Set Some reusable info ;-------------------------- Dim $szServerPC = @ComputerName ; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address ;Dim $szIPADDRESS = TCPNameToIP($szServerPC) Dim $szIPADDRESS = "192.168.0.2" Dim $nPORT = 33891 ; Initialize a variable to represent a connection ;============================================== Dim $ConnectedSocket = -1 ;Attempt to connect to SERVER at its IP and PORT 33891 ;======================================================= $ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT) Dim $szData ; If there is an error... show it If @error Then MsgBox(4112,"Error","TCPConnect failed with "&$szIPADDRESS&" error: " & @error) ; If there is no error loop an inputbox for data ; to send to the SERVER. Else ;Loop forever asking for data to send to the SERVER While 1 ; InputBox for data to transmit $szData = InputBox("Invio",@LF & @LF & "Scrivi:") ; If they cancel the InputBox or leave it blank we exit our forever loop If @error Or $szData = "" Then ExitLoop ; We should have data in $szData... lets attempt to send it through our connected socket. TCPSend($ConnectedSocket,$szData) ; If the send failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop WEnd EndIf expandcollapse popup;SERVER!! Start Me First !!!!!!!!!!!!!!! #include <GUIConstants.au3> ; Set Some reusable info ; Set your Public IP address (@IPAddress1) here. Dim $szIPADDRESS = @IPAddress1 Dim $nPORT = 33891 ; Start The TCP Services ;============================================== TCPStartUp() ; Create a Listening "SOCKET". ; Using your IP Address and Port 33891. ;============================================== $MainSocket = TCPListen($szIPADDRESS, $nPORT) ; If the Socket creation fails, exit. If $MainSocket = -1 Then Exit ; Create a GUI for messages ;============================================== Dim $GOOEY = GUICreate("Server",300,200) Dim $edit = GUICtrlCreateEdit("",10,10,280,180) GUISetState() ; Initialize a variable to represent a connection ;============================================== Dim $ConnectedSocket = -1 ;Wait for and Accept a connection ;============================================== Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 ; Get IP of client connecting Dim $szIP_Accepted = SocketToIP($ConnectedSocket) Dim $msg, $recv ; GUI Message Loop ;============================================== While 1 $msg = GUIGetMsg() ; GUI Closed ;-------------------- If $msg = $GUI_EVENT_CLOSE Then ExitLoop ; Try to receive (up to) 2048 bytes ;---------------------------------------------------------------- $recv = TCPRecv( $ConnectedSocket, 2048 ) ; If the receive failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop ; Update the edit control with what we have received ;---------------------------------------------------------------- If $recv <> "" Then GUICtrlSetData($edit, _ $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit)) WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket ) TCPShutDown() ; Function to return IP Address from a connected socket. ;---------------------------------------------------------------------- Func SocketToIP($SHOCKET) Local $sockaddr = DLLStructCreate("short;ushort;uint;char[8]") Local $aRet = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET, _ "ptr",DLLStructGetPtr($sockaddr),"int_ptr",DLLStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc Link to comment Share on other sites More sharing options...
d4rk Posted June 11, 2008 Share Posted June 11, 2008 This's not strange, go to the first Sticky page in General Help And Support Forum, you'll see what you need [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys 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