Multiple Connections
Multiple Connections
Multiple Connections
Multiple Connections
Multiple Connections
Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections
Multiple Connections Multiple Connections
Multiple Connections
Go Back  Xtreme Visual Basic Talk > > > Multiple Connections


Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2003, 11:56 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default Multiple Connections


I feel like an idiot but...I am clueless about making multiple connections with winsock. On top of that, I don't know how to make the server send things to everyone. It's probably just me but I don't really understand the tutorials on WinsockVB.com...

Could someone help me out a little?

Thanks.
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #2  
Old 03-14-2003, 01:59 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

ok i explain the best i can did you read the tuturiol on multiple connections at www.winsockvb.com?? basicly the only differance is insted of just sending the data you have to add it to an array (guessing you got that far)

Code:
Public Sub SendOnArray(ByVal Data As String) Dim i As Integer ' loop through array, sending on each socket For i = 0 To Winsock.Count - 1 ' make sure we're connected If Winsock(i).State = sckConnected Then Winsock(i).SendData Data DoEvents End If Next i End Sub
thats for sending infomation...

Code:
Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal RequestID As Long) ' we should only be getting connection requests from ' Index 0 because thats the only one that is listening ' load a new winsock Load Winsock(Winsock.UBound + 1) ' accept the incoming connection on our new control Winsock(Winsock.UBound).Accept RequestID End Sub
add this to your connection request procedur

its really quite simple and i find it hard to explain ha... i am sure there is abetter exaple on the forum let me find it for you....
Reply With Quote
  #3  
Old 03-14-2003, 02:04 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

http://www.xtremevbtalk.com/showthre...ck+connections

here are two good exaples hope i helped u i know its hard at first but you will get it eventully and you will find it usefull so dont give up .......
Reply With Quote
  #4  
Old 03-14-2003, 02:08 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

Reply With Quote
  #5  
Old 03-14-2003, 06:44 AM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

http://www.winsockvb.com/article.php?article_id=18
http://www.winsockvb.com/article.php?article_id=19

Both are great tutorials on makeing multiple connections with winsock.
Reply With Quote
  #6  
Old 03-14-2003, 10:12 AM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

rust he said he doesnt undertand the tuturiols on www.winsockVb.com thats y i went through all that code (well tried to) but i find it hard to explain....
Reply With Quote
  #7  
Old 03-14-2003, 01:55 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Opps missed that. I guess I really shouldn't be answering these post so earily in the morning.

Vinx, I am pretty good with multiple connections so if you have a question please ask.
Reply With Quote
  #8  
Old 03-14-2003, 05:43 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default

Well it's just in general I find them hard to understand...

I don't know how to send to one user or to send info to all users
I don't know how to fill in an empty array if someone leaves
I don't know how to make connections in the first place
I don't know how to limit the number of connections...
etc..etc..etc...

I am sorry for being annoying and stupid
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #9  
Old 03-15-2003, 02:18 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Ok. When in control arrays the server has each connection in an array. So to send data to just one user you would say winsock1(1).SendData Data. The 1 in parentisis is the connection you want to send data to. To send data to all you need to loop through and individually send data to each connection.

To fill empty space. When you recive a connection you say Load Winsock(Winsock.UBound + 1). Well when some one disconnects you have a problem. If the person that disconnected was the highest connection number then I like to get rid of it. UnLoad Winsock(X). If it is not then just leave it alone. When you get your next connection request check all the spots in the array if one is sitting eating space put it to work and make it take the new connection.

To make connections. It is just like winsock with out control array except on the server side you moving the connection a little.

To limit. It is your choice to accept the connection or not. If you don't say Winsock.Accept requestID it will never be excepted.

I hope I was clear enough. Any other questions or what ever feel free to ask.
Reply With Quote
  #10  
Old 03-15-2003, 05:11 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default

OK I sort of get it. But how do I make it check for each spot to see if there's an opening?
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #11  
Old 03-16-2003, 11:28 AM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Code:
for X = 1 to winsock.ubound if winsock(X).State <> sckConnected then MsgBox X & " is not connected. end if Next X
Reply With Quote
  #12  
Old 03-16-2003, 12:17 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default

So I can have it loop and then find a free socket and let someone connect to it?

Thanks!
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #13  
Old 03-16-2003, 12:29 PM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

ok people me and vinx are the same no matter what i have tried and i been at this all day i cant manage to grasp the idea will someone please just give us the most basic example u can make! thank you
Reply With Quote
  #14  
Old 03-16-2003, 01:31 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

hi Sorry VBProgrammer & vinx

I will be writing one of these in a few weeks but not yet as I'm finishing my College work.

But I will try to help as much as i can

the pig..
Reply With Quote
  #15  
Old 03-16-2003, 02:13 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default

No I get it now.

I'm almost done with the Winsock part of my MUD now.

Thanks to everyone who helped!
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #16  
Old 03-16-2003, 02:17 PM
Vinx's Avatar
Vinx Vinx is offline
Contributor
 
Join Date: Dec 2002
Location: Los Angeles, CA
Posts: 559
Default

I'm pretty sure this is all I need on the server side not including the data arrival:

Code:
Private Sub FrmVegaServer_Load() Winsock.LocalPort = "18690" 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 End Sub

And then to send I can either send to all the indexs using a loop or they index of the user who sent it to me like this:

Code:
Winsock(Index).Senddata "Bla"

Am I doing anything wrong or is this fine?
__________________
"I may be a coward, but I'm a greeeeeedy little coward!!!" - Daffy Duck
Reply With Quote
  #17  
Old 03-16-2003, 02:28 PM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

u know in the ubound bit shudnt we have the loop to look for a spare place?
Reply With Quote
  #18  
Old 03-16-2003, 02:37 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

dont forget check that all of the controls on the array are in use before loading a new control.

This saves time and memory because why make a new control when you can use an existing closed one.

the pig..
Reply With Quote
  #19  
Old 03-16-2003, 03:43 PM
Squidge Squidge is offline
Restricted
 
Join Date: Mar 2003
Location: Manchester! England!
Posts: 872
Default

so piggy where do i put the checker thing to check for the spare places?
Reply With Quote
  #20  
Old 03-16-2003, 04:01 PM
pitbull pitbull is offline
Newcomer
 
Join Date: Mar 2003
Posts: 2
Wink

can i use this winsock control for my program here http://www.xtremevbtalk.com/t67070.html
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why I can't create multiple DSNs for ODBC connections for Sybase? chaogao Database and Reporting 2 01-23-2003 08:49 PM
Multiple Connections in Winsock -_-; Chrono23 Communications 6 01-10-2003 01:56 PM
Multiple connections ? daedalus_hammer Communications 4 11-25-2002 04:20 PM
Sending Data - Multiple Connections Sarboras Communications 12 05-09-2002 02:59 PM
Multiple connections Probe Communications 1 04-11-2002 05:20 AM

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
Multiple Connections
Multiple Connections Multiple Connections
Multiple Connections
Multiple Connections
Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections Multiple Connections
Multiple Connections
Multiple Connections
 
Multiple Connections
Multiple Connections
 
-->