jusb3 Posted May 1, 2014 Share Posted May 1, 2014 I have tried to do a TCP listener, to track some traffic from certain address. I have tried this test-script: TCPStartup() $ip = "195.143.118.113" $port = "4217" Global $TCPL = TCPListen($ip, $port) Do $TCPA = TCPAccept($TCPL) Until $TCPA <> -1 Do Global $TCPR = TCPRecv($TCPA, 9999999) Until $TCPR <> "" MsgBox(0, "Data", $TCPR) There certinly is traffic, but the listener doesn't respond, is there something wrong with my script? Link to comment Share on other sites More sharing options...
JohnOne Posted May 1, 2014 Share Posted May 1, 2014 I'm pretty certain TCP traffic generally only sends data to one process, meaning with this native function you cannot intercept traffic meant for another application (pretty certain). Try to explain a little more about what you're trying to accomplish. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jusb3 Posted May 1, 2014 Author Share Posted May 1, 2014 I'm trying to do an client for a server, and this listener is one part of it. It can be as you say, since i have tested this associated with an alternative certainly working client. Link to comment Share on other sites More sharing options...
JohnOne Posted May 1, 2014 Share Posted May 1, 2014 be helpful then if you posted your server script. Or maybe this is the server script in which case post the client script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jusb3 Posted May 6, 2014 Author Share Posted May 6, 2014 be helpful then if you posted your server script. Or maybe this is the server script in which case post the client script. Sorry for my late answer. The server is online, not hosted by me. I'm just connecting to it. Here is the code I have now: TCPStartup() $ip = "195.143.118.113" $port = "4217" Global $tcp = TCPConnect($ip, $port) TCPSend($tcp, _HexToString("3C706F6C6963792D66696C652D726571756573742F3E00") & @CRLF& @CRLF) TCPCloseSocket($tcp) Global $tcp = TCPConnect($ip, $port) TCPSend($tcp, '{"type":"conn","data":{"cmd":"hello"}}' & @CRLF& @CRLF) Global $TCPL = TCPListen($ip, $port) Do Global $TCPA = TCPAccept($TCPL) Until $TCPA <> -1 Do Global $TCPR = TCPRecv($TCPA, 1024) Until $TCPR <> "" MsgBox(0, "Data", $TCPR) When I run this script I get right response from server, but the listener part still does not react anyway. Link to comment Share on other sites More sharing options...
Danp2 Posted May 6, 2014 Share Posted May 6, 2014 This appears to be for a game. Suggest that you read the forum rules, which are located at the bottom right of each page. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jusb3 Posted May 6, 2014 Author Share Posted May 6, 2014 This appears to be for a game. Suggest that you read the forum rules, which are located at the bottom right of each page. Okay, sorry missed that one. I would still like to know in general how to listen TCP traffic Link to comment Share on other sites More sharing options...
Alexxander Posted May 6, 2014 Share Posted May 6, 2014 (edited) try this TCPStartup() $ip = "195.143.118.113" $port = "4217" Global $TCPL = TCPListen($ip, $port) while 1 $TCPA = TCPAccept($TCPL) $TCPR = TCPRecv($TCPA, 9999999) if $TCPR <> "" then MsgBox(0, "Data", $TCPR) wend if you need a good tcp TUT see this link: Edited May 6, 2014 by Alexxander Link to comment Share on other sites More sharing options...
jusb3 Posted May 6, 2014 Author Share Posted May 6, 2014 (edited) try this TCPStartup() $ip = "195.143.118.113" $port = "4217" Global $TCPL = TCPListen($ip, $port) while 1 $TCPA = TCPAccept($TCPL) $TCPR = TCPRecv($TCPA, 9999999) if $TCPR <> "" then MsgBox(0, "Data", $TCPR) wend if you need a good tcp TUT see this link: When I use TCPListen, should I use local or remote address? Right now I'm using remote address. And if I have to use local, how can I determine the right port? Edited May 6, 2014 by jusb3 Link to comment Share on other sites More sharing options...
Alexxander Posted May 6, 2014 Share Posted May 6, 2014 When I use TCPListen, should I use local or remote address? Right now I'm using remote address. And if I have to use local, how can I determine the right port? you want your script to listen for the device ip you could use @ipadress if you are on local network if you are using the internet you must check you pc ip then listen to it note: when using internet tcp you must be port forwarded and if you are a noob with tcp stuff i advice u to try first on 2 local PCs or virtual machine then make it through internet Link to comment Share on other sites More sharing options...
jusb3 Posted May 6, 2014 Author Share Posted May 6, 2014 (edited) Does it make any difference if I'm client or server, because I'm the client, and when I connect to the server, the whole sever-client converstion happens trough single socket, so all I would have to do is get the port at the point I connect and use that port for the rest of the session. I live in apartment, and cannot access the router, so I can't use port forwarding? Edited May 6, 2014 by jusb3 Link to comment Share on other sites More sharing options...
Alexxander Posted May 6, 2014 Share Posted May 6, 2014 Does it make any difference if I'm client or server, because I'm the client, and when I connect to the server, the whole sever-client converstion happens trough single socket, so all I would have to do is get the port at the point I connect and use that port for the rest of the session. I live in apartment, and cannot access the router, so I can't use port forwarding? i cant get your idea ,the part before " so I can't use port forwarding?" is another question or is description of the situation that wont let u port forward ? anyway you can port forward without physical access to the router this site will guide you how http://portforward.com/ to check if you are port forwarder use canyouseeme.org Link to comment Share on other sites More sharing options...
Solution jusb3 Posted May 6, 2014 Author Solution Share Posted May 6, 2014 (edited) EDIT: I have been able to solve my problem: I had to skip the TCPListen and TCPAccept, and use TCPRecv directly on $tcp, because TCPListen seems to open new connection. Hope this is useful for someone else too. Edited May 7, 2014 by jusb3 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