Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
AnswerRe: TextBox Pin
MoustafaS30-Apr-07 9:21
MoustafaS30-Apr-07 9:21 
Questiondll Pin
netJP12L30-Apr-07 8:08
netJP12L30-Apr-07 8:08 
AnswerRe: dll Pin
Christian Graus30-Apr-07 12:04
protectorChristian Graus30-Apr-07 12:04 
QuestionDataGridView Pin
Mohammed Elkholy30-Apr-07 7:34
Mohammed Elkholy30-Apr-07 7:34 
QuestionCreating classes that use the web / app.config for initialization Pin
Tristan Rhodes30-Apr-07 6:24
Tristan Rhodes30-Apr-07 6:24 
AnswerRe: Creating classes that use the web / app.config for initialization Pin
Pete O'Hanlon30-Apr-07 9:07
mvePete O'Hanlon30-Apr-07 9:07 
GeneralRe: Creating classes that use the web / app.config for initialization Pin
Tristan Rhodes1-May-07 3:14
Tristan Rhodes1-May-07 3:14 
Questiontcp/ip socket Pin
Harikrk30-Apr-07 5:48
Harikrk30-Apr-07 5:48 
i am working on a project to communicate with clinets using tcp/ip protocol.
I have a server system where this program is being done. I have clinets which are connnected to my ip. These clients are capable of accepting commands from the server and gove reply for that. For eg:- if i give %Name to clinet it will send back the system ip address.


private void button1_Click(object sender, EventArgs e)
{
Listener = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any,5005);
Listener.Bind(ipLocal);
Listener.BeginAccept(new AsyncCallback(OnClientConnect), null);
}

private void OnClientConnect(IAsyncResult asyn)
{
Client = Listener.EndAccept(asyn);
WaitForData();
}

private void WaitForData()
{
Client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(OnDataReceived), null);
}

private void OnDataReceived(IAsyncResult asyn)
{
Byte[] sendBytes = Encoding.UTF8.GetBytes("%Name");
string szData;
int iRx = 0 ;
iRx = Client.EndReceive(asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(buffer, 0, iRx, chars, 0);
szData = new string(chars);
MessageBox.Show(szData.ToString());
Client.Send(sendBytes);
WaitForData();
}
The sending of data is working fine here. but when i revceive data they are all junk values even after converting to string. Junk vlaues means some single characters only
Please let me know if tehre is someone extertise in this feild as i am new to this
Thanks in advance


Harikrishnan
AnswerRe: tcp/ip socket Pin
pbraun30-Apr-07 12:17
pbraun30-Apr-07 12:17 
QuestionCheckbox in Gridview Pin
Bubbles230-Apr-07 5:41
Bubbles230-Apr-07 5:41 
QuestionHow to communicate VisualStudio2005 with Microsoft Info Path Pin
pashitech30-Apr-07 4:24
pashitech30-Apr-07 4:24 
QuestionScreenshots with DirectX Pin
wimme30-Apr-07 4:09
wimme30-Apr-07 4:09 
Questioncollection Pin
arkiboys30-Apr-07 3:48
arkiboys30-Apr-07 3:48 
AnswerRe: collection Pin
Colin Angus Mackay30-Apr-07 3:58
Colin Angus Mackay30-Apr-07 3:58 
GeneralRe: collection Pin
arkiboys30-Apr-07 4:02
arkiboys30-Apr-07 4:02 
GeneralRe: collection Pin
Colin Angus Mackay30-Apr-07 4:39
Colin Angus Mackay30-Apr-07 4:39 
GeneralRe: collection Pin
arkiboys30-Apr-07 4:04
arkiboys30-Apr-07 4:04 
AnswerRe: collection Pin
Karthik Kalyanasundaram30-Apr-07 4:05
Karthik Kalyanasundaram30-Apr-07 4:05 
GeneralRe: collection Pin
arkiboys30-Apr-07 4:06
arkiboys30-Apr-07 4:06 
GeneralRe: collection Pin
Pete O'Hanlon30-Apr-07 22:19
mvePete O'Hanlon30-Apr-07 22:19 
Questionproblem in software updation of the application manually Pin
praveenkumar palla30-Apr-07 3:46
praveenkumar palla30-Apr-07 3:46 
AnswerRe: problem in software updation of the application manually Pin
Judah Gabriel Himango30-Apr-07 3:53
sponsorJudah Gabriel Himango30-Apr-07 3:53 
GeneralRe: problem in software updation of the application manually Pin
praveenkumar palla30-Apr-07 4:10
praveenkumar palla30-Apr-07 4:10 
GeneralRe: problem in software updation of the application manually Pin
Judah Gabriel Himango30-Apr-07 7:06
sponsorJudah Gabriel Himango30-Apr-07 7:06 
AnswerRe: problem in software updation of the application manually Pin
kubben30-Apr-07 4:08
kubben30-Apr-07 4:08 

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.