E1M1 Posted February 12, 2010 Share Posted February 12, 2010 (edited) Hello, I am trying to make simple proxy, but how do I listen server responce? I see packet sent by client, and I send that packet to server, but how do I listen server's responce and how do i send it to client? I have tried to copy this script and cnanged 127.0.0.1 to @ipAddress1 so I had 2 standalone scripts, but thatway it didn't work. Any other ideas how to listen server responce and send it to client? if you look at how I forward packet to server, what do you say: Is this ok?Here's little illustration expandcollapse popup#include <GUIConstantsEx.au3> ;~ Opt('MustDeclareVars', 1) ;============================================== ;============================================== ;SERVER!! Start Me First !!!!!!!!!!!!!!! ;============================================== ;============================================== Example() Func Example() ; Set Some reusable info ; Set your Public IP address (@IPAddress1) here. ; Local $szServerPC = @ComputerName ; Local $szIPADDRESS = TCPNameToIP($szServerPC) Local $szIPADDRESS = "127.0.0.1";localip Local $nPORT = 22;tcp port for login and chatlobby local $remoteszIPADDRESS = "213.248.106.204";Server Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted Local $msg, $recv ; 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 ;============================================== $GOOEY = GUICreate("proxy (IP: " & $szIPADDRESS & ")", 800, 200) $edit = GUICtrlCreateEdit("", 10, 10, 780, 180) GUISetState() ; Initialize a variable to represent a connection ;============================================== $ConnectedSocket = -1 ;Wait for and Accept a connection ;============================================== Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 $remoteConnectedSocket = TCPConnect($remoteszIPADDRESS, $nPORT) ;~ MsgBox(0,0,$remoteConnectedSocket) ; Get IP of client connecting $szIP_Accepted = SocketToIP($ConnectedSocket) ; 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)) ConsoleWrite(TCPSend($remoteConnectedSocket,$recv)&@CRLF);debug EndIf WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() EndFunc ;==>Example ; Function to return IP Address from a connected socket. ;---------------------------------------------------------------------- Func SocketToIP($SHOCKET) Local $sockaddr, $aRet $sockaddr = DllStructCreate("short;ushort;uint;char[8]") $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int*", 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 ;==>SocketToIP Edited February 14, 2010 by E1M1 edited Link to comment Share on other sites More sharing options...
E1M1 Posted February 16, 2010 Author Share Posted February 16, 2010 bump edited Link to comment Share on other sites More sharing options...
Developers Jos Posted February 16, 2010 Developers Share Posted February 16, 2010 mmmm removed 3 bumps and bump it again... Wondering how long you continue this. 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. Link to comment Share on other sites More sharing options...
E1M1 Posted February 17, 2010 Author Share Posted February 17, 2010 mmmm removed 3 bumps and bump it again... Wondering how long you continue this.Just wanted to clean it abit.how long I continue this?Until I get some helpWhat's the bump rule for this site? 24 hour? edited Link to comment Share on other sites More sharing options...
Developers Jos Posted February 17, 2010 Developers Share Posted February 17, 2010 What's the bump rule for this site? 24 hour?Correct, but there will be a time that it will be closed.I would think that after 4 bumps without a single reply that there is a slight chance that the question "isn't clear"/"too complex"/"too much work before anyone can test"/"whatever else" for anybody to touch it, it would dawn on you that you need to do some work first yourself.... or does this really sound ridiculous?Jos 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. Link to comment Share on other sites More sharing options...
E1M1 Posted February 17, 2010 Author Share Posted February 17, 2010 (edited) Rght. I have done what I could,now I just need little hink about how to go on with it. Is my question unclear or too complex or what I did wrong with tis topic?? I know my english isn't always clear but i usually get some hints/help. Do you have any idea about what I could try? Edited February 17, 2010 by E1M1 edited Link to comment Share on other sites More sharing options...
E1M1 Posted February 18, 2010 Author Share Posted February 18, 2010 bump edited Link to comment Share on other sites More sharing options...
LoWang Posted February 20, 2010 Share Posted February 20, 2010 Is it just my feeling or are there increasingly more people having problems and less experienced people willing to help them here? I have seen several interesting questions unanswered just today... I have some experience with UDP, but not TCP. I plan to try something with TCP in the near future though... Link to comment Share on other sites More sharing options...
doucment Posted March 16, 2010 Share Posted March 16, 2010 Look this: http://www.autoitscript.com/forum/index.php?showtopic=44138&st=0&p=328722&hl=proxy&fromsearch=1&#entry328722 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