|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET Winsock Multithreading question.I have a problem with my current program. The meaning of the program is to allow users to login to a server to allow them to access the internet. My program communicates with a MS isa server to make a rule for that IP for the time-credits left for that user. My problem is that so far, the program can handle everything except more then one client, and i have done my best, but i can't find a decent solution to get my winsock multithreaded. i'll show you my code: Code: #Region " Windows Form Designer generated code " Friend WithEvents Winsock3 As Winsock_Control.Winsock Friend WithEvents Winsock1 As Winsock_Control.Winsock Friend WithEvents Winsock2 As Winsock_Control.Winsock '...... <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Winsock1 = New Winsock_Control.Winsock Me.Winsock2 = New Winsock_Control.Winsock Me.Winsock3 = New Winsock_Control.Winsock '.... End Sub #End Region Private Sub Winsock1_ConnectionRequest(ByVal sender As Winsock_Control.Winsock, ByVal requestID As System.Net.Sockets.Socket) Handles Winsock1.ConnectionRequest Winsock3.Accept(requestID) Winsock3.Send("Connected") txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() & ") Incoming Connection..." & ControlChars.CrLf End Sub Private Sub startlisten() 'initialised under form_load ofcourse :) Winsock1.Listen() txtlog.Text &= "Listening..." & ControlChars.CrLf End Sub Private Sub Winsock3_DataArrival(ByVal sender As Winsock_Control.Winsock, ByVal BytesTotal As Integer) Handles Winsock3.DataArrival Dim s As String Dim str As String Dim pass As String Dim login As String Dim IP As String Dim oRijndael As New Rijndael("[filtered away :] ]") Dim substr As String = "!!_!_!!" Winsock3.GetData(s) IP = Winsock3.RemoteHostIP login = s.Substring(0, s.IndexOf(substr)) pass = oRijndael.Decrypt(s.Substring(s.IndexOf(substr) + 7), "[filtered away :] ]") txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() & ") Incoming data...: LOGIN=" & login & "" & ControlChars.CrLf txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() & ") Incoming data...: PASSWORD=[encrypted]" & s.Substring(s.IndexOf(substr) + 7) & "" & ControlChars.CrLf 'send login , pass & ip for verification loggebruikerin(login, pass, IP) 'End If End Sub Any help would be very welcome, because i'm really stuck with this project Show quoteHide quote :) . I did something similar in a program that accepts multiple simultaneous
connections from SMTP mail servers. You might want to download it and take a look at the code and how I implemented multi-threading (it's open source): http://spamgrinderprox.sourceforge.net/ Show quoteHide quote "Nicolas Ghesquiere" <the_de***@skynet.be> wrote in message news:44c8e471$0$1215$ba620e4c@news.skynet.be... > Hello > > I have a problem with my current program. > The meaning of the program is to allow users to login to a server to allow > them to access the internet. > My program communicates with a MS isa server to make a rule for that IP for > the time-credits left for that user. > > My problem is that so far, the program can handle everything except more then > one client, and i have done my best, but i can't find a decent solution to get > my winsock multithreaded. > > > i'll show you my code: > > > Code: > > #Region " Windows Form Designer generated code " > Friend WithEvents Winsock3 As Winsock_Control.Winsock > Friend WithEvents Winsock1 As Winsock_Control.Winsock > Friend WithEvents Winsock2 As Winsock_Control.Winsock > '...... > <System.Diagnostics.DebuggerStepThrough()> Private Sub > InitializeComponent() > Me.components = New System.ComponentModel.Container > Me.Winsock1 = New Winsock_Control.Winsock > Me.Winsock2 = New Winsock_Control.Winsock > Me.Winsock3 = New Winsock_Control.Winsock > '.... > End Sub > > #End Region > > Private Sub Winsock1_ConnectionRequest(ByVal sender As > Winsock_Control.Winsock, ByVal requestID As System.Net.Sockets.Socket) Handles > Winsock1.ConnectionRequest > Winsock3.Accept(requestID) > Winsock3.Send("Connected") > txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() > & ") Incoming Connection..." & ControlChars.CrLf > End Sub > > Private Sub startlisten() > 'initialised under form_load ofcourse :) > Winsock1.Listen() > txtlog.Text &= "Listening..." & ControlChars.CrLf > End Sub > > Private Sub Winsock3_DataArrival(ByVal sender As Winsock_Control.Winsock, > ByVal BytesTotal As Integer) Handles Winsock3.DataArrival > Dim s As String > Dim str As String > Dim pass As String > Dim login As String > Dim IP As String > Dim oRijndael As New Rijndael("[filtered away :] ]") > Dim substr As String = "!!_!_!!" > > Winsock3.GetData(s) > IP = Winsock3.RemoteHostIP > login = s.Substring(0, s.IndexOf(substr)) > pass = oRijndael.Decrypt(s.Substring(s.IndexOf(substr) + 7), "[filtered > away :] ]") > txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() > & ") Incoming data...: LOGIN=" & login & "" & ControlChars.CrLf > txtlog.Text &= "[" & Now.ToLocalTime & "] (" & Winsock3.RemoteHostIP() > & ") Incoming data...: PASSWORD=[encrypted]" & s.Substring(s.IndexOf(substr) + > 7) & "" & ControlChars.CrLf > > 'send login , pass & ip for verification > loggebruikerin(login, pass, IP) > 'End If > End Sub > > > > > > Any help would be very welcome, because i'm really stuck with this project :) > . >
if then endif
Rank newbie question - Class or Function? VB Removing multiple items from a multi-select ListView how to speed up collections iteration How to access and use Unmanaged Code VStudio 2003 and 2005 on the same workstation? Dynamically adding in User Controls Using ListView's VirtualMode Updating DataTable bound to a DataGridView |
|||||||||||||||||||||||