Click here to Skip to main content
15,892,072 members
Home / Discussions / C#
   

C#

 
QuestionVOIP Vonage Answering Machine Pin
steveharper605-Sep-06 2:12
steveharper605-Sep-06 2:12 
AnswerRe: VOIP Vonage Answering Machine Pin
Erik Funkenbusch5-Sep-06 21:43
Erik Funkenbusch5-Sep-06 21:43 
QuestionRe: VOIP Vonage Answering Machine Pin
steveharper606-Sep-06 7:31
steveharper606-Sep-06 7:31 
QuestionHow to make client server Pin
King Shez5-Sep-06 1:50
King Shez5-Sep-06 1:50 
AnswerRe: How to make client server Pin
samtam5-Sep-06 2:25
samtam5-Sep-06 2:25 
AnswerRe: How to make client server Pin
Andrei Ungureanu5-Sep-06 2:50
Andrei Ungureanu5-Sep-06 2:50 
GeneralRe: How to make client server Pin
King Shez5-Sep-06 20:48
King Shez5-Sep-06 20:48 
GeneralRe: How to make client server Pin
Andrei Ungureanu6-Sep-06 7:37
Andrei Ungureanu6-Sep-06 7:37 
Well,
It is very important to understand that sockets exchange only byte arrays between them, regardless of what the byte arrays contain (file, string message etc.). So it is very important that when you receive something to know what you receive. At first you should try to create your own communication protocol.
In my example the client send a string message and the server receives it

For the server:
<br />
Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);<br />
m_tcpListener.Bind(new IPEndPoint(IPAddress.Any,10000>)); // 10000 is the port number<br />
Socket client = server.Accept(); // accepts a connection from a client<br />
byte []buffer = new byte[1024];<br />
int read = 0;<br />
string receivedMessage = "";<br />
while ( (read = client.Receive(buffer)) != 0 )<br />
{<br />
  receivedMessage = String.Concat(Encoding.ASCII.GetString(buffer),receivedMessage);<br />
  if (read < buffer.Length)<br />
    break;<br />
}<br />
client.Shutdown(SocketShutdown.Both);<br />

For the client:
<br />
Socket client = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);<br />
client.Connect(new IPEndPoint(Dns.Resolve("127.0.0.1").AddressList[0],10000));<br />
string message = "This is a test";<br />
client.Send(Encoding.ASCII.GetBytes(message));<br />
client.Shutdown(SocketShutdown.Both);<br />


Hope it helps

Do your best to be the best

GeneralRe: How to make client server Pin
King Shez6-Sep-06 20:55
King Shez6-Sep-06 20:55 
GeneralRe: How to make client server Pin
Andrei Ungureanu7-Sep-06 3:02
Andrei Ungureanu7-Sep-06 3:02 
AnswerRe: How to make client server Pin
Rob Philpott5-Sep-06 4:36
Rob Philpott5-Sep-06 4:36 
GeneralRe: How to make client server Pin
King Shez5-Sep-06 21:10
King Shez5-Sep-06 21:10 
Questioncrystal Report problem Pin
ranandbe5-Sep-06 1:27
ranandbe5-Sep-06 1:27 
AnswerRe: crystal Report problem Pin
trannguyen865-Sep-06 1:47
trannguyen865-Sep-06 1:47 
GeneralRe: crystal Report problem Pin
ranandbe5-Sep-06 2:49
ranandbe5-Sep-06 2:49 
QuestionEncrypted Connection Strings in app.config Pin
Gomac5-Sep-06 1:03
Gomac5-Sep-06 1:03 
AnswerRe: Encrypted Connection Strings in app.config Pin
Gomac5-Sep-06 5:39
Gomac5-Sep-06 5:39 
QuestionReturning value from threads Pin
samtam5-Sep-06 0:43
samtam5-Sep-06 0:43 
AnswerRe: Returning value from threads Pin
WillemM5-Sep-06 1:58
WillemM5-Sep-06 1:58 
QuestiondataGridView Pin
charbelasmar5-Sep-06 0:25
charbelasmar5-Sep-06 0:25 
AnswerRe: dataGridView Pin
Nader Elshehabi5-Sep-06 12:06
Nader Elshehabi5-Sep-06 12:06 
Questionhow to set focus to a child form after I clicked a TreeNode? Pin
CooperWu5-Sep-06 0:05
CooperWu5-Sep-06 0:05 
QuestionCOleVariant in C# ? Pin
anderslundsgard4-Sep-06 23:33
anderslundsgard4-Sep-06 23:33 
AnswerRe: COleVariant in C# ? Pin
Guffa5-Sep-06 0:46
Guffa5-Sep-06 0:46 
GeneralRe: COleVariant in C# ? Pin
anderslundsgard6-Sep-06 1:54
anderslundsgard6-Sep-06 1:54 

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.