Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Socket Programming
Message
De
13/01/2007 02:23:27
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Socket Programming
Divers
Thread ID:
01185331
Message ID:
01185331
Vues:
84
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...
Music Rocks www.musicreserve.blogspot.com
Success is 1% Inspiration & 99% Perspiration
God Sometimes Delays His Help to Test Our Faith and Energize Our Prayers
Our Boat May Be Tossed While He Sleeps, But He Wakes Up Before it Sinks.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform