hi my name is vishal for past 2 days i have been breaking my head on how to make winsock control to allow maximum of 20 clients to be connected at once in c# windows forms.
I have a form named:
Form1 in which i have 1 winsock control named:
Winsock1 along with some buttons and textboxes.
I did a research and found out below code worked the same functionality of winsock control Just what what i needed but unfortunately it was in vb6 code.
Given below is
vb6 code with winsock control named:
Winsock1 with which i was able to achieve the same functionality in vb6 with Ms access. :
Private Sub Form_Load()
Dim x As Integer
For x = 1 To 20
Load sckClient(x)
sckClient(x).Close
Next
StartListen
End Sub
Private Function StartListen()
sckServer.Close
sckServer.LocalPort = 25000
sckServer.Listen
End Function
where
sckClient is name of one of my Winsock controls in
vb6 and
sckServer is name of my another Winsock control in
vb6.
Given below is my c# code interpretation of above vb6 code:
namespace DRRS_Socket_Application
{
public partial class Form1 : Form
{
Socket sck;
EndPoint epLocal;
const string DELIM = "***";
const string EOP = "???";
int counter;
public Form1()
{
InitializeComponent();
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
}
private void StartListen()
{
sckServer.Close();
sckServer.LocalPort = 25000;
sckServer.Listen();
}
private void Form1_Load(object sender, EventArgs e)
{
}
I have 2 Winsock controls named:
sckServer and
sckClient in my
Form1. I am able to correctly code
StartListen() in c# windows forms. But i am not able/correctly code (c#) of
sckClient(Winsock control) in allowing 20 clients to be connected at once in c# windows forms.
I am supposed to use only Winsock control in c# windows forms because of my
Boss orders and cannot use TCP Classes or other things.
Can anyone help me on how to make my winsock(sckClient) in allowing 20 clients to be connected at once in c# windows forms.Can anyone help me please? Any help/guidance in solving of this problem would be greatly appreciated!