Click here to Skip to main content
15,892,697 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
VikashGohil3-Jan-09 18:36
VikashGohil3-Jan-09 18:36 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
Dave Kreskowiak4-Jan-09 0:05
mveDave Kreskowiak4-Jan-09 0:05 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
VikashGohil4-Jan-09 21:02
VikashGohil4-Jan-09 21:02 
AnswerRe: Client-Server Using TCP/IP and VB.net Pin
Mark Salsbery3-Jan-09 7:09
Mark Salsbery3-Jan-09 7:09 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
VikashGohil3-Jan-09 18:37
VikashGohil3-Jan-09 18:37 
AnswerRe: Client-Server Using TCP/IP and VB.net Pin
Bharat Jain6-Jan-09 1:13
Bharat Jain6-Jan-09 1:13 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
VikashGohil6-Jan-09 6:04
VikashGohil6-Jan-09 6:04 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
Bharat Jain7-Jan-09 2:25
Bharat Jain7-Jan-09 2:25 
Hi Vikas ,

The only idea that come to my mind is
we will maintain of connect client (in a list object) , when ever a client tries to connect we will call a function (implementation on the function is as given below ), which will a loop through the list and use the connected property to find if the client is still connected , the implementation of the function goes like this

Private Function NumberOfClientConnected() As Integer
Dim tempclient As TcpClient
Dim totalClientConnected As Integer
totalClientConnected = 0
For Each tempclient In connectedClients
If tempclient.Connected Then
totalClientConnected = totalClientConnected + 1
Else
connectedClients.Remove(tempclient)
End If
Next
Return totalClientConnected
End Function


for this you have to declare a Module level variable of type list , remember its a module level variable.

Dim connectedClients As New List(Of TcpClient)

Also there is a small change in the previous code after
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()

we need to add the following line
connectedClients.Add(tcpClient)

Also before Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
We need to add a if condition

If NumberOfClientConnected() > <maxclientallowe> then
Exit sub
End If

So the summary is
1) We maintain a list to TCPClient Connected
2) Then we loop through the list and check for still connected client by using the Connected property
3) If the server has not reached the maximum number of client connected , we accept the connection and add it to the list..

I hope it is helpful , i am sorry if there are any build error , i have not tried it in the IDE , i dont have one installed right now Smile | :) , i am i hurry right now , need to go .........

Let me know if it was ok or not

-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com

GeneralRe: Client-Server Using TCP/IP and VB.net Pin
VikashGohil7-Jan-09 20:43
VikashGohil7-Jan-09 20:43 
GeneralRe: Client-Server Using TCP/IP and VB.net Pin
Bharat Jain11-Jan-09 22:41
Bharat Jain11-Jan-09 22:41 
QuestionHow to access objects of an arraylist, where an object property is selected in a Listbox? Pin
SvenatGMX2-Jan-09 1:46
SvenatGMX2-Jan-09 1:46 
AnswerRe: How to access objects of an arraylist, where an object property is selected in a Listbox? Pin
Brij2-Jan-09 3:08
mentorBrij2-Jan-09 3:08 
QuestionIME Pin
iprasad0071-Jan-09 20:04
iprasad0071-Jan-09 20:04 
AnswerRe: IME Pin
Abhijit Jana1-Jan-09 20:23
professionalAbhijit Jana1-Jan-09 20:23 
GeneralRe: IME Pin
iprasad0074-Jan-09 17:28
iprasad0074-Jan-09 17:28 
AnswerRe: IME Pin
Brij1-Jan-09 20:27
mentorBrij1-Jan-09 20:27 
Questionhelp!!!! Pin
saadahmedsait1-Jan-09 8:24
saadahmedsait1-Jan-09 8:24 
AnswerRe: help!!!! Pin
Dave Kreskowiak1-Jan-09 11:19
mveDave Kreskowiak1-Jan-09 11:19 
GeneralRe: help!!!! Pin
Luc Pattyn1-Jan-09 12:04
sitebuilderLuc Pattyn1-Jan-09 12:04 
GeneralRe: help!!!! Pin
Jon_Boy2-Jan-09 2:25
Jon_Boy2-Jan-09 2:25 
GeneralRe: help!!!! Pin
saadahmedsait2-Jan-09 7:12
saadahmedsait2-Jan-09 7:12 
GeneralRe: help!!!! Pin
Mark Churchill3-Jan-09 15:58
Mark Churchill3-Jan-09 15:58 
JokeRe: help!!!! Pin
Guffa4-Jan-09 19:53
Guffa4-Jan-09 19:53 
AnswerStop spamming the forums! Pin
leckey1-Jan-09 12:53
leckey1-Jan-09 12:53 
GeneralRe: Stop spamming the forums! Pin
saadahmedsait1-Jan-09 20:46
saadahmedsait1-Jan-09 20:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.