Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!!
Multiple Connection torcher please help!! Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Go Back  Xtreme Visual Basic Talk > > > Multiple Connection torcher please help!!


Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2004, 03:39 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Question Multiple Connection torcher please help!!


Hi there,

I'm lost with this multiple connection, I've managed to successfully to get a single client connected to my server, but rewriting it to take multiple connections is torcher , I've had a look at many examples but i've become so confused to say the least.

Here is the ClsSocketServer
Code:
Public Class ClsSocketServer Dim m_Port As Int32 Dim m_Backlog As Int32 Dim MyServerSocket As System.net.sockets.Socket Dim BindAddress As System.Net.IPAddress Dim BindEndPoint As System.Net.IPEndPoint Dim ipadds As ClsIPAddresses 'Event Declarations: Event OnServerStarted(ByVal Address As String, ByVal Port As Int32) Event OnServerStop() Event OnConnectionRequest() Public Sub New() ipadds = New ClsIPAddresses End Sub <System.ComponentModel.DefaultValue(CInt(6000)), System.ComponentModel.Description("Sets the Port Number to use")> _ Public Property PortNumber() As Int32 Get Return m_Port End Get Set(ByVal Value As Int32) If Value < System.Net.IPEndPoint.MinPort Or Value > System.Net.IPEndPoint.MaxPort Then MessageBox.Show("You must enter a Port Number between " & CStr(System.Net.IPEndPoint.MinPort) & " and " & CStr(System.Net.IPEndPoint.MaxPort), "Port Number Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Property End If m_Port = Value End Set End Property <System.ComponentModel.DefaultValue(CInt(5)), System.ComponentModel.Description("Sets the Simultaneous Connections to use")> _ Public Property SimultaneousConnections() As Int32 Get Return m_Backlog End Get Set(ByVal Value As Int32) If Value < 1 Or Value > System.Net.Sockets.SocketOptionName.MaxConnections Then MessageBox.Show("You must enter a Simultaneous Connections between 1 and " & CStr(System.Net.Sockets.SocketOptionName.MaxConnections), "Simultaneous Connections Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Property End If m_Backlog = Value End Set End Property Public Sub StartServer() BindAddress = System.Net.IPAddress.Parse(ipadds.HostIPAddress(ClsIPAddresses.Addresses.NetworkIP)) BindEndPoint = New System.Net.IPEndPoint(BindAddress, m_Port) MyServerSocket = New System.Net.sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp) MyServerSocket.Bind(BindEndPoint) MyServerSocket.Listen(m_Backlog) RaiseEvent OnServerStarted(ipadds.HostIPAddress(ClsIPAddresses.Addresses.NetworkIP), m_Port) MyServerSocket.BeginAccept(New AsyncCallback(AddressOf ConnectionRequest), MyServerSocket) End Sub Public Sub StopServer() MyServerSocket.Shutdown(Net.Sockets.SocketShutdown.Both) MyServerSocket.Close() RaiseEvent OnServerStop() End Sub Public Sub ConnectionRequest(ByVal ar As IAsyncResult) Dim Local_ClientSocket As System.net.sockets.Socket Local_ClientSocket = CType(ar.AsyncState, System.net.sockets.Socket) ' MyClientSocket = Local_ClientSocket.EndAccept(ar) 'Try ' If MyClientSocket.Connected = False Then ' Console.WriteLine("Connection refused.", Err.Number) ' Exit Sub ' Else 'MyClientSocket.BeginReceive(Buffer, 0, BufferSize, 0, AddressOf OnData_Arrival, MyClientSocket) ' End If 'Catch ' Exit Sub 'End Try RaiseEvent OnConnectionRequest() MyServerSocket.BeginAccept(New AsyncCallback(AddressOf ConnectionRequest), MyServerSocket) End Sub End Class

I've commented out some of the client connection code as this will need changing for mulitple connections (I think).


And here is the Address Class ClsIPAddresses

Code:
Public Class ClsIPAddresses Dim AddressArray() As String Dim HostName As String Public Enum Addresses NetworkIP = 0 InterenetIP = 1 End Enum Public Sub New() HostName = System.Net.Dns.GetHostName() ReDim AddressArray(System.Net.Dns.GetHostByName(HostName).AddressList.Length - 1) For A As Int32 = 0 To System.Net.Dns.GetHostByName(HostName).AddressList.Length - 1 AddressArray(A) = System.Net.Dns.GetHostByName(HostName).AddressList(A).ToString Next A End Sub Public Function HostIPAddress(ByVal Address As Addresses) As String Select Case Address Case ClsIPAddresses.Addresses.NetworkIP Return AddressArray(0) Case ClsIPAddresses.Addresses.InterenetIP Return AddressArray(1) End Select End Function End Class

I know its not relatively hard, but its one of these things thats hard to get your head around to change I'm not sure of several things, and inevitably change it.

Not sure abouts

(1) when a person connects, i need a way to figure out after they have sent data who they are(ID number), so i can direct this to the right Table for the data to get parased(Threads).

(2) Can i make a ClsClientSocket class but have this indexed. but if i do how do i know the person who has sent the data.

as you can see i'm going way ahead of myself but i must to find out which one my work.

Please help even if you think its not worth mentioning something it may put me on the right track.

The pig.....

Last edited by piggybank1974; 11-01-2004 at 03:44 AM.
Reply With Quote
  #2  
Old 11-01-2004, 03:07 PM
petbo petbo is offline
Newcomer
 
Join Date: May 2004
Posts: 20
Default

This may help.
Reply With Quote
  #3  
Old 11-02-2004, 01:58 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Question

I'm sorry dude but thats, VB not VB.net yes the principal is sort of the same but NOT.

I think i've sort of cracked it, it sort of came to me in a flash just yesterday morning so i think but as of yet i'm still code both Apps(Server and client) to make sure, but early indications look good as the Conntections and dat are flowing.


the pig..
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 Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!! Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!! Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
 
Multiple Connection torcher please help!!
Multiple Connection torcher please help!!
 
-->