Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Socket Programming
Message
 
To
13/01/2007 02:23:27
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01185331
Message ID:
01185921
Views:
15
I just found this: http://www.codeproject.com/useritems/winsock2005.asp


>Hi Guys,
>
>I'm trying to do socket programming to pass messages from a client program to another program in the server.
>
>The problem occurs when I started sending a string messages on the Server. The following is my code for sending
>
>
> try
> {
>    String szData = "Hello There";
>    byte[] byData= System.Text.Encoding.ASCII.GetBytes(szData);
>    m_clientSocket.SendBufferSize = 1024;
>    m_clientSocket.Send(byData, byData.Length,SocketFlags.None);
> }
>
> catch (SocketException se)
> {
>    MessageBox.Show ( se.Message );
> }
>
>
>The server receives the string as:
>H
>e
>l
>l
>o
>
>T
>h
>e
>r
>e
>
>it seems that the data is being sent on a per character basis not as a whole string. Is there something that I missed on my code?
>
>By the way, here is the code on how I connect the client program to the server:
>
>
>m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
>
>IPAddress ip = IPAddress.Parse(textBoxIP.Text);
>int iPortNo = System.Convert.ToInt16 ( textBoxPort.Text);
>IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);
>m_clientSocket.Connect ( ipEnd );
>
>
>Thanks in advance...
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Reply
Map
View

Click here to load this message in the networking platform