Jump to content

Listen on port TCP


 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...