Click here to Skip to main content
15,896,454 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i will describe it briefly. i need to create a dll class to establish a socket communication and that dll class i should use it between the client App and the server App. but the main task is not done yet which is how to enforce editing to the display controls in both Apps by the Class functions. that is it. any help will be appreciated.

for example the following is the logic we use for client Connect

//=================
public void ClientConnect(string ServerIP, string Port)
{ try
{ // Create the socket instance
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

// Cet the remote IP address
//IPAddress ip = IPAddress.Parse(ServerIP.ToString());
//int iPortNo = System.Convert.ToInt16(Port);
// Create the end point
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse(ServerIP.ToString()), Convert.ToInt16(Port));
// Connect to the remote host
m_clientSocket.Connect(ipEnd);
if (m_clientSocket.Connected)
{
//Wait for data asynchronously
WaitForDataClient();
}
}
catch (SocketException se)
{
string str;
str = "\nConnection failed, is the server running?\n" + se.Message;
//MessageBox.Show(str);
}
}

i put this in a Class so it becomes like this:

ClientServerCom MySocket = new ClientServerCom(); // here is the Class Object Declaration

MySocket.ClientConnect(textBoxIP.Text, textBoxPort.Text); // here is establishing the Connection

now you got the idea, what i missing here is how to enforce any control on the server App to display the received messages once the client thread send it. i know i have to specify by coding a specific function on the server side to override another function in the created socket class and that what i'm trying to do.
please help in this good idea.
Posted
Updated 2-Apr-15 14:53pm
v3
Comments
Sergey Alexandrovich Kryukov 2-Apr-15 10:55am    
It does not seem to make any sense. Not even the question, but your whole approach. Better invent something else.

If you need more help, ask the question differently, starting with the explanation of your final goals and scenarios on top level, before discussing your views on possible implementations.

—SA
Richard MacCutchan 2-Apr-15 11:16am    
A DLL is merely a library of helper classes/functions/methods, "dll class" does not really make much sense. And neither does the rest of your question.
Richard MacCutchan 3-Apr-15 3:44am    
I would suggest you Google for articles on the use of sockets. There are many samples around which will explain what happens at both the server and client ends.
moabdel 4-Apr-15 11:54am    
thank you all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900