Click here to Skip to main content
16,005,125 members
Home / Discussions / C#
   

C#

 
QuestionTextfile and its schema Pin
Mahi.Ragava13-Dec-05 18:19
Mahi.Ragava13-Dec-05 18:19 
AnswerRe: Textfile and its schema Pin
MarcelErz13-Dec-05 22:03
MarcelErz13-Dec-05 22:03 
GeneralRe: Textfile and its schema Pin
Mahi.Ragava13-Dec-05 22:09
Mahi.Ragava13-Dec-05 22:09 
GeneralRe: Textfile and its schema Pin
MarcelErz13-Dec-05 22:37
MarcelErz13-Dec-05 22:37 
GeneralRe: Textfile and its schema Pin
Mahi.Ragava13-Dec-05 23:01
Mahi.Ragava13-Dec-05 23:01 
GeneralRe: Textfile and its schema Pin
MarcelErz14-Dec-05 0:31
MarcelErz14-Dec-05 0:31 
QuestionSend Message Pin
picasso213-Dec-05 17:55
picasso213-Dec-05 17:55 
AnswerRe: Send Message Pin
MarcelErz13-Dec-05 22:28
MarcelErz13-Dec-05 22:28 
Hi!

If you want to send a message with TCP to a special port: that is not really so easy, coz you have first to establish the connection. UDP is easier, coz it is connectionless and you can directly send it to the port. Anyway! Here a short description about TCP:

<br />
// Instance for TCP connection<br />
System.Net.Sockets.TcpClient loTcp = new System.Net.Sockets.TcpClient();<br />
<br />
try {<br />
<br />
 loTcp.Connect("127.0.0.1", 80); // Host to send the data<br />
 System.Net.Sockets.NetworkStream loStream = loTcp.GetStream(); // Getting the connection stream<br />
<br />
 // Preparing the sending data<br />
 Byte[] lbOutData = System.Text.Encoding.ASCII.GetBytes("This is a text message!");<br />
<br />
 loStream.Write(lbOutData, 0, lbOutData.Length); // write the data to stream (send)<br />
<br />
 loTcp.Close(); // close the connection<br />
<br />
} catch (Exception loErr) {<br />
 MessageBox.Show("Network error: " + loErr.ToString()); // Error occured<br />
}<br />


for UDP the following code can be used:

<br />
Byte[] lbOutData = System.Text.Encoding.ASCII.GetBytes("This is a text message!");<br />
System.Net.Sockets.UdpClient loUdp = new System.Net.Sockets.UdpClient();<br />
			<br />
try <br />
{<br />
 loUdp.Send(lbOutData, lbOutData.Length, "127.0.0.1", 80);<br />
} <br />
 catch (Exception loErr) <br />
{<br />
 MessageBox.Show("Network error: " + loErr.ToString());<br />
}<br />


Marcel Erz
QuestionDatagridTextBoxColumn with Combo Pin
Mahi.Ragava13-Dec-05 17:49
Mahi.Ragava13-Dec-05 17:49 
QuestionList of Funny Generics Pin
Clickok13-Dec-05 17:07
Clickok13-Dec-05 17:07 
AnswerRe: List of Funny Generics Pin
Christian Graus13-Dec-05 17:15
protectorChristian Graus13-Dec-05 17:15 
AnswerRe: List of Funny Generics Pin
leppie13-Dec-05 23:08
leppie13-Dec-05 23:08 
QuestionGraphics.PageScale Problem when scrolling Pin
-Rowan-13-Dec-05 15:26
-Rowan-13-Dec-05 15:26 
QuestionOracle Querying in C# Pin
apoc50313-Dec-05 14:14
apoc50313-Dec-05 14:14 
AnswerRe: Oracle Querying in C# Pin
Christian Graus13-Dec-05 15:06
protectorChristian Graus13-Dec-05 15:06 
GeneralRe: Oracle Querying in C# Pin
apoc50314-Dec-05 9:05
apoc50314-Dec-05 9:05 
Questionnew to c# Pin
lino_i13-Dec-05 13:58
lino_i13-Dec-05 13:58 
AnswerRe: new to c# Pin
Christian Graus13-Dec-05 15:03
protectorChristian Graus13-Dec-05 15:03 
AnswerRe: new to c# Pin
Kevin McFarlane14-Dec-05 5:14
Kevin McFarlane14-Dec-05 5:14 
Questiondataset Pin
fmardani13-Dec-05 11:45
fmardani13-Dec-05 11:45 
AnswerRe: dataset Pin
bloo2k13-Dec-05 16:47
bloo2k13-Dec-05 16:47 
QuestionHow to filter datatable and send Pin
kotteeswaran13-Dec-05 11:21
kotteeswaran13-Dec-05 11:21 
QuestionVSTO and Excel Hyperlinks Pin
Drew McGhie13-Dec-05 10:38
Drew McGhie13-Dec-05 10:38 
Questiondifferences please !!! Pin
faviochilo13-Dec-05 9:50
faviochilo13-Dec-05 9:50 
QuestionHow to raise Mouse click event Pin
bloo2k13-Dec-05 9:49
bloo2k13-Dec-05 9:49 

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.