Jump to content
Sign in to follow this  
Erik.

Listen on port TCP

Recommended Posts

Erik.

Hello,

I wanted to listen to an port, like msn port 1863.

I tried to use TCP listen, accept, port scan etc. I can not get it working.

When i try to use tcp resv i got the erorr 0. Or i thought 10061.

Could you please help me to got the listen working.

Kind regards., Erik

edit:

Example:

;SERVER!! Start Me First !!!!!!!!!!!!!!!
$g_IP = "127.0.0.1"

; Start The TCP Services
;==============================================
TCPStartUp()

; Create a Listening "SOCKET"
;==============================================
$MainSocket = TCPListen($g_IP, 1863,  100 )
If $MainSocket = -1 Then Exit

It looks like that TCP accept gives the error, for example the program wireshark that can also listen to the ports.

I already found out to use wincap.

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
Andreik

Try this code:

TCPStartup()
$SERVER = TCPListen("127.0.0.1",1863)
If @error Then
    MsgBox(0,"Error",@error)
    Exit
EndIf

While True
    Do
        $SOCKET = TCPAccept($SERVER)
        Sleep(10)
    Until $SOCKET <> -1
    TrayTip("Connected","Someone connect to server.",3)
    While True
        $RECV = TCPRecv($SOCKET,512)
        If $RECV = "Hello" Then TCPSend($SOCKET,"The server receive your message.")
        Sleep(10)
    WEnd
    Sleep(10)
WEnd

You just use an universal client to connect and say Hello to server and if server started correctly should work.


When the words fail... music speaks

Share this post


Link to post
Share on other sites
Erik.

Hi,

Thanks for the fast response.

The program is only running this part:

Do
        $SOCKET = TCPAccept($SERVER)
        Sleep(10)
    Until $SOCKET <> -1

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
Andreik

Hi,

Thanks for the fast response.

The program is only running this part:

Do
        $SOCKET = TCPAccept($SERVER)
        Sleep(10)
    Until $SOCKET <> -1

Until you connect to server and then run second loop with data received from client.

When the words fail... music speaks

Share this post


Link to post
Share on other sites
Erik.

I understand.

What i am trying is to make an package sniffer so i can see all packages that are coming in on a port.

Is this the correct way or do i need to find another way to do that?


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
Andreik

Check this and this.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
Erik.

I already found the first link,

second one is new for me, does not work but i will try it.

Thank you:)


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.