TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
or nakash
NA
23
0
Help with Asynchronous Sockets [OnDataReceived]
Feb 19 2010 3:42 PM
Hey.
I am new with the Asynchronous sockets and I am trying to make a little program.
I want when the client sends the string "doitall", the server does something, I succeeded to do that with the client but I faild with the server. This is the code:
public void OnDataReceived(IAsyncResult asyn)
{
try
{
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState;
int byteCount = 0;
byteCount = theSockId.thisSocket.EndReceive(asyn);
char[] chars = new char[byteCount + 1];
Encoding.UTF8.GetDecoder().GetChars(theSockId.dataBuffer, 0, byteCount, chars, 0);
string str = new string(chars);
AppendText(str);
if (str == "doitall")
{
MessageBox.Show("works.");
}
WaitForData(m_socWorker);
}
catch (SocketException se)
{
MessageBox.Show(se.Message);
}
}
Whats the problem?
And how to send data to a specific IP address?
Reply
Answers (
3
)
Best overall reporting package?
To Show XML File Inside RichTextBox With updation of text capability after clicking a button.