Monday, June 30, 2014

how to create control array of winsock control control/controls in c# windows forms

Dear Mr.Muthukrishnan Ramasamy


Thank you for replying to my post/query. After reading your reply. I have changed my c# code. Given below is my c# code:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
namespace DRRS_Socket_Application
{
public partial class Form1 : Form
{
private AxMSWinsockLib.AxWinsock axWinsock1;
private AxMSWinsockLib.AxWinsock[] sckClient = new AxMSWinsockLib.AxWinsock[20];
public Form1()
{
InitializeComponent();
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
}
private void Form1_Load(object sender, EventArgs e)
{
int x;
for (x = 0; x < 20; x++)
{
sckClient[x]=new AxMSWinsockLib.AxWinsock();
((System.ComponentModel.ISupportInitialize)(this.axWinsock1)).BeginInit();
sckClient[x].Enabled = true;
axWinsock1.EndInit();
StartListen();
}
}
private void StartListen()
{
sckServer.Close();
sckServer.LocalPort = 25000;
sckServer.Listen();
}

Is this enough for creating control array of winsock control in c# windows forms? Or should i need to create Active X Control((Winsock control) from scratch in designer.cs in c# windows forms? Reply please Sir? I am waiting for your reply!?



vishal


No comments:

Post a Comment