Gif Posted May 13, 2007 Posted May 13, 2007 SERVER: expandcollapse popup#include <GUIConstants.au3> $waitin_ip = InputBox("enter", "ip to connect to..") Dim $nPORT = 33891 Dim $szIPADDRESS = $waitin_ip TCPStartUp() $MainSocket = TCPListen($szIPADDRESS, $nPORT) if $mainsocker = -1 then exit Dim $GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")",300,200) Dim $edit = GUICtrlCreateEdit("",10,10,280,180, $ES_READONLY + $WS_VSCROLL) GUISetState() Dim $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 Dim $szIP_Accepted = SocketToIP($ConnectedSocket) Dim $msg, $recv While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv( $ConnectedSocket, 2048 ) If @error Then ExitLoop If $recv <> "" Then GUICtrlSetData($edit, _ $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit)) WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket ) TCPShutDown() 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 EndFuncoÝ÷ Ø"ÈÔÚºÚ"µÍÚ[ÛYH ÑÕRPÛÛÝ[Ë]LÉÝÂÔÝ B[H ÌÍÚÛÛXÝYH[]Þ ][ÝØÛÛXÝ ][ÝË ][ÝÝÜ]HHÙHÛÛ]][ÝHÛÝ[ZÙHÈÛÛXÝË][ÝÊB[H ÌÍÜÞTQTÔÈH ÌÍÚÛÛXÝY[H ÌÍÛÔHÌÎLB[H ÌÍÐÛÛXÝYÛØÚÙ]HLBÌÍÐÛÛXÝYÛØÚÙ]HÔÛÛXÝ ÌÍÜÞTQTÔË ÌÍÛÔ B[H ÌÍÑÓÓÑVHHÕRPÜX]J ][ÝØÛÛXÝÈÙ T ][ÝÈ [È ÌÍÜÞTQTÔÈ [È ][ÝÊI][ÝË B[H ÌÍÜÞ]HHÕRPÝÜX]R[] ][ÝÉ][ÝËLLÌJB[H ÌÍÜÙ[HÕRPÝÜX]P]Û ][ÝÜÙ[ ][ÝËÌL JBÕRTÙ]Ý]J BYÜ[ÙÐÞ ][ÝÑÜ][ÝË ][ÝØØ[ÝÛÛXÝ ][ÝÊB[ÙBÚ[HB ÌÍÛÙÈHÕRQÙ]ÙÊ BÙ[XÝØÙH ÌÍÛÙÈH ÌÍÑÕRWÑUSÐÓÔÑB^]ÛÜØÙH ÌÍÛÙÈH ÌÍÜÙ[ÔÙ[ ÌÍÐÛÛXÝYÛØÚÙ]ÕRPÝXY ÌÍÜÞ]JJB[Ù[XÝÑ[[Y the server accepts messages only from the computer that the server is runnning? how can i change this and allow the client to connect to the server globaly? please help...
Developers Jos Posted May 13, 2007 Developers Posted May 13, 2007 Why create a second thread when you already have one on this subject ? *click* SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts