PDA

Click to See Complete Forum and Search --> : WInsock


noname
Aug 15th, 2000, 04:21 AM
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

Sophtware
Aug 15th, 2000, 10:25 AM
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)

noname
Aug 15th, 2000, 10:02 PM
Thanks for that but,
How would you make a msgbox display if there was now connection made?

thanks in advance

Sophtware
Aug 16th, 2000, 02:19 AM
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...

Crypt
Aug 16th, 2000, 03:38 AM
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:


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]