multiple connections to port?
multiple connections to port?
multiple connections to port?
multiple connections to port?
multiple connections to port?
multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port?
multiple connections to port? multiple connections to port?
multiple connections to port?
Go Back  Xtreme Visual Basic Talk > > > multiple connections to port?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2005, 05:35 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default multiple connections to port?


anyone know who to have multiple connections to a single server? Sofar I can only have one user connected to my server, and its not fun to talk to your self.
Reply With Quote
  #2  
Old 02-24-2005, 06:12 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

Reply With Quote
  #3  
Old 02-24-2005, 06:26 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

Finally some one answers to one of my posts here! ive been waiting for hours!!!

Ok, I actualy just started learning Winsock last night, and i learned what I know so far from winsockvb.com.

I got up to the multiple connections tut, and this is where i got lost. I could not follow that at all, it was very poorly written. I got the basic idea down, but since Im totaly new to this, and visual basic in general (5 months) it didnt really help much.

This is what I got after reading those tutorials, and surfing the web for about 5 hours.

I am stuck on an error message that says:
"Procedure does not match description of event or procedure having same name "

It points to the top line of code that I have include below. Private sub ....

Code:
Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal RequestID As Long) For i = 0 To UBound(Winsock) Next i Winsock.Close Winsock.Accept RequestID End Sub End Sub

I dont know where to go from here.
Reply With Quote
  #4  
Old 02-24-2005, 06:42 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

you have to set the index property on your control to 0 on your form

and then your going to want to change those to Winsock(Index).whatever

and maybe you should go back and re-read one or both of those tutorials, i know the first one is pretty clear and clean, you've got several mistakes there.
Reply With Quote
  #5  
Old 02-24-2005, 06:44 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

It was set to 0 when i got that error message.

If i had executed the program before with it having no index, would I need to replace the old winsock with a new one? Because before when I was just having one connection It had no index value. It wasnt until I started trying to add multiple connections that I gave it an index value of 0.

Ok, ive made the suggested changes, and ive come up with the same error for this code section.

Code:
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long) Dim strData As String Winsock.GetData strData For i = 0 To UBound(Winsock) If Winsock(i).Status = sckConnected Then Winsock(i).SendData strData DoEvents End If Next i txtConsole.Text = txtConsole.Text & vbCrLf & strData txtConsole.SelStart = Len(txtConsole.Text) End Sub

Ill save time and post my whole source file here for viewing.

Code:
Option Explicit Private Sub Form_Load() Winsock.LocalPort = 10101 Winsock.Listen End Sub Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal RequestID As Long) Load Winsock(Winsock.UBound + 1) Winsock(Winsock.UBound).Accept RequestID For i = 0 To UBound(Winsock) Next i Winsock(Index).Close Winsock(Index).Accept RequestID End Sub Private Sub Winsock_DataArrival(ByVal bytesTotal As Long) Dim strData As String Winsock.GetData strData For i = 0 To UBound(Winsock) If Winsock(i).Status = sckConnected Then Winsock(i).SendData strData DoEvents End If Next i txtConsole.Text = txtConsole.Text & vbCrLf & strData txtConsole.SelStart = Len(txtConsole.Text) End Sub

Last edited by Frantic-; 02-24-2005 at 06:49 PM.
Reply With Quote
  #6  
Old 02-24-2005, 06:45 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

that's right, but you wouldn't have to erplace it, just take away the index. But ya go back and re-read atleast that first tutorial
Reply With Quote
  #7  
Old 02-24-2005, 06:50 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

im reading the 1st tut again, and maybe perhaps i looked at it the wrong way. Am i supposed to at form load have the for loop just createa bunch of winsocks, and then make extra subs and or functions to manage the opening,closing and connecting to the ports, and if all are used then say "Sorry we're full "

Or perhaps the above could be one way to go about it.

Last edited by Frantic-; 02-24-2005 at 06:58 PM.
Reply With Quote
  #8  
Old 02-24-2005, 07:02 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

well... you could do it that way, or as i believe that first tut i showed you makes a new control each connection request...
Reply With Quote
  #9  
Old 02-24-2005, 07:05 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

well in your DataArrival, you need to add Index As Integer into the parameters of the sub, and then user Winsock(Index) instead of just Winsock
Reply With Quote
  #10  
Old 02-24-2005, 07:09 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

Should I add index into parts that already have a (value) after them?

UBound(Winsock)

should i make it UBound(Winsock(index))
Reply With Quote
  #11  
Old 02-24-2005, 07:13 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

no, UBound just takes the name of the array, also in your for loop, don't change those (i) to (Index) you'll need that i to send to all connected clients
Reply With Quote
  #12  
Old 02-24-2005, 07:30 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

ok im down to what i think if either the last or 2nd last problem, atleast with my server.

I ran into another compilation error, and i tried to fix it, but ran into a second error when i "fixed" it. I will list.

When i ran the code as is, i got a message saying
" Method or data member not found "
and it pointed to winsock.localport = 10101 and highlighted LocalPort =

it pointed to the form load which is located below.

Code:
Private Sub Form_Load() Winsock.LocalPort = 10101 Winsock.Listen End Sub

I went and made the following changes to the form load, which are shown below.

Code:
Private Sub Form_Load() Winsock(index).LocalPort = 10101 Winsock(index).Listen End Sub

I got this error message.
" variable not defined "
and it pointed to the winsock(index).localport = 10101 and highlighted index.
Reply With Quote
  #13  
Old 02-24-2005, 07:31 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

winsock(0) ... your first control...
Reply With Quote
  #14  
Old 02-24-2005, 07:47 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

Updated form load:

Code:
Private Sub Form_Load() Dim i As Integer For i = 1 To 5 Load Winsock(i) Next i Winsock(0).LocalPort = 10101 Winsock(0).Listen End Sub

now its telling me that UBound is an expected array.
Reply With Quote
  #15  
Old 02-24-2005, 07:51 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

don't load any to begin with, take that out, and load them like you were before in your connection request
Reply With Quote
  #16  
Old 02-24-2005, 07:57 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

same error.

"Expected Array"

It it highlighting UBound found in the following code.

Code:
Private Sub Winsock_DataArrival(index As Integer, ByVal bytesTotal As Long) Dim strData As String Winsock(index).GetData strData For i = 0 To UBound(Winsock) If Winsock(i).Status = sckConnected Then Winsock(i).SendData strData DoEvents End If Next i txtConsole.Text = txtConsole.Text & vbCrLf & strData txtConsole.SelStart = Len(txtConsole.Text) End Sub
Reply With Quote
  #17  
Old 02-24-2005, 08:17 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

oops, lol use Winsock.count -1 instead, i believe it even shows that in one of those tuts
Reply With Quote
  #18  
Old 02-24-2005, 08:20 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

Ok ive made that change, now its telling me "method or data member not found" for winsock(i).status

Code:
If Winsock(i).Status = sckConnected Then

Code:
Private Sub Winsock_DataArrival(index As Integer, ByVal bytesTotal As Long) Dim strData As String Winsock(index).GetData strData Dim i As Integer For i = 0 To Winsock.Count - 1 If Winsock(i).Status = sckConnected Then Winsock(i).SendData strData DoEvents End If Next i txtConsole.Text = txtConsole.Text & vbCrLf & strData txtConsole.SelStart = Len(txtConsole.Text) End Sub
__________________
Saint Anger Round My Neck, He Never Gets Respect...

http://www.xiemnetwork.cjb.net
Reply With Quote
  #19  
Old 02-24-2005, 08:28 PM
Illusionist's Avatar
Illusionist Illusionist is offline
Senior Contributor
 
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
Default

where did Status come from? it should be State
Reply With Quote
  #20  
Old 02-24-2005, 08:32 PM
Frantic- Frantic- is offline
Centurion
 
Join Date: Dec 2004
Location: New York
Posts: 111
Default

lol, everything i know came from reading online tuts

Ill soon be investing in some nice books, do you have any reccomendations?

Ok this time it actualy compiled!!!

I ran it, and logged on. The client was able to connect, but then the server generated an error dialog box saying

"Invalid Control Array Index"
__________________
Saint Anger Round My Neck, He Never Gets Respect...

http://www.xiemnetwork.cjb.net
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
multiple connections to port?
multiple connections to port?
multiple connections to port? multiple connections to port?
multiple connections to port?
multiple connections to port?
multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port? multiple connections to port?
multiple connections to port?
multiple connections to port?
 
multiple connections to port?
multiple connections to port?
 
-->