Winsock control on ports

Winsock checking ports

Page 1 of 1

1 Replies - 3919 Views - Last Post: 20 July 2005 - 09:16 AM Rate Topic: -----

#1 burndailer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 06-June 05

Winsock control on ports

Post icon  Posted 20 July 2005 - 08:25 AM

So people i'm back.

I've finaly found to work with the winsock command for transfer a message.
At this moment it works fine at one port example.:

Private sub senddatabutton()
Winsock1.LocalPort = 21             'it makes port 21 open.
Winsock1.Listen                         'it listen to that port
end sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
  Winsock1.Close
  Winsock1.Accept requestID
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Result As String
  Winsock1.GetData Result
  Select Case Left(Result, 3)
      Case "msg"
    Text3.Text = Text3.Text & "Pc_1_: " & Mid(Result, _
                 4) & vbCrLf
    Text3.SelStart = Len(Text3.Text)
    End Select
End Sub



Now is my question, is there a possibility that, if i want to juse the program on 3 pc's, that the program tests if port 21 is in juse by the first pc that he swith to port 22 or 23 ??
I'm only interested if that is a possibility and how?
So people lets juse our brains together ;)

Is This A Good Question/Topic? 0
  • +

Replies To: Winsock control on ports

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 250
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Winsock control on ports

Posted 20 July 2005 - 09:16 AM

Are you asking if you can switch the port that is listened to? The answer is yes. Currently, you have port 21 hardcoded in your function. All you need to do is apply a conditional statement that will determine which port is open, then listen to that port. Here is an implementation of a function that checks the staus of a port.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1