473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

VB.NET Winsock Multithreading question.

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
:) .
Jul 27 '06 #1
1 5400
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/

"Nicolas Ghesquiere" <th*******@skynet.bewrote in message
news:44**********************@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 :)
.

Jul 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
7
by: Nadav | last post by:
Hi I am writing some kind of a storage system that have to deal with large amounts of data passing over the net, Now, I Wonder... traditional programming would use win32 Winsock DLL as the means...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
5
by: kc | last post by:
Hi Just upgrading a app from VB6 to VB.Net. All is going well apart from the Winsock control. The first thing we notice is that there does not appear to be a .Net version (please correct me if...
0
by: gnanapoongothai | last post by:
hi, i have to develope a client sever modal in which around 32 clients will be connected and send data at 1MBps rate. the sever has to store it in hard after alligning it. so for this scenario...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
3
AaronL
by: AaronL | last post by:
Hello, I am currently working on a project that has me in sort of a bind. What I want to do is retrieve web pages from the internet, and strip them down to just text. I'll get using Regular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.