SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old June 12th, 2004, 08:20 AM
zwonimir zwonimir is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: East Side Verona, Southern Europe
Posts: 98 zwonimir User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
howto connect 2 hosts with Winsock

I've tried my software with me like the server and I didn't receive the Connection Request from the client ...
the IP address used by the client is exact, I think there's something wrong with the ports ...

both server and client must use the same port number? Or need only 2 free ports, the number is indifferent?

my code:
Quote:
Private Sub cmdConnect_Click()
[...]
Select Case True
' Option1 is a switch between Server(0) and Client(1)
Case Option1(0).Value:
ws1.Close
ws1.LocalPort = 0
ws1.Listen
lblStato.Caption = "... listening ..."
lblStato.ForeColor = RGB(255, 100, 0)

Case Option1(1).Value:
ws1.Close
ws1.LocalPort = CInt(txtPort.Text)
ws1.Connect txtIP.Text, txtPort.Text
lblStato.Caption = "... connecting ..."
lblStato.ForeColor = RGB(255, 100, 0)
End Select
[...]
End Sub

Private Sub ws1_Connect()
lblStato.Caption = "Connected"
lblStato.ForeColor = RGB(0, 255, 0)
connesso = True
cmdConnetti.Picture = il2.ListImages(2).Picture
cmdConnetti.Caption = "Disconnect"
txtUtente.Enabled = False
txtFrase.Enabled = True
End Sub

'this sub is 4 the server when the request is arrived
Private Sub ws1_ConnectionRequest(ByVal requestID As Long)
If ws1.State <> sckClosed Then ws1.Close
ws1.Accept requestID
lblStato.Caption = "Connected"
lblStato.ForeColor = RGB(0, 255, 0)
connesso = True
cmdConnetti.Picture = il2.ListImages(2).Picture
cmdConnetti.Caption = "Disconnect"
txtUtente.Enabled = False
txtFrase.Enabled = True
End Sub

Private Sub ws1_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)
MsgBox Description, vbOKOnly + vbCritical, "Error " + CStr(Number)
End Sub
Thx

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > howto connect 2 hosts with Winsock


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway