Results 1 to 5 of 5

Thread: WInsock

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    Question

    I was wandering if it is possible by coding for wincsock to display a message when a connection is made to an IP on a specific port. If so how would you do it?

    Thanks in Advanced

  2. #2
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Wink Like dis

    Try this,


    'Server:


    Private Sub Form_Load()
    Winsock1.LocalPort = 1134
    Winsock1.Listen
    End Sub




    'Client

    Private Sub Command1_Click()
    Winsock1.Connect "127.0.0.1", 1134
    End Sub


    Private Sub Winsock1.Connect()
    MsgBox "Connection Made!"
    End Sub

    ' This message box will only fire if Connection has been made.









    Visual Basic,Vbscript,JAVA,(Still trying)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    23

    No connection

    Thanks for that but,
    How would you make a msgbox display if there was now connection made?

    thanks in advance

  4. #4
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Wink Well just try this..

    Using a winsock control,

    Winsock1.Closed
    msgbox "closed"
    end sub



    i forgot where i placed it too make it work..cause everytime i tried to make the message box appear to infor me that the connection was closed i kept getting aloop between the "Open" and "closed" message box and i had to ctrl-alt-del my program...

  5. #5
    Addicted Member
    Join Date
    Apr 2000
    Posts
    215
    you use the winsock error sub, because when a connection could not be established it returns it to this sub with the error number 11001, example:

    Code:
    Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    If Number = 11001 Then
    winsock1.close
    MsgBox "No Connection Established"
    End If
    End Sub

    [Edited by Crypt on 08-16-2000 at 04:45 AM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width