Click here to Skip to main content
15,909,332 members
Home / Discussions / C#
   

C#

 
QuestionConvert generic data to bytes Pin
j.newger17-Jun-08 4:56
j.newger17-Jun-08 4:56 
AnswerRe: Convert generic data to bytes Pin
Anthony Mushrow17-Jun-08 5:01
professionalAnthony Mushrow17-Jun-08 5:01 
GeneralRe: Convert generic data to bytes Pin
j.newger17-Jun-08 5:09
j.newger17-Jun-08 5:09 
AnswerRe: Convert generic data to bytes Pin
Le centriste17-Jun-08 5:07
Le centriste17-Jun-08 5:07 
QuestionRemote DataBase Access Pin
ahmedsamir17-Jun-08 4:34
ahmedsamir17-Jun-08 4:34 
AnswerRe: Remote DataBase Access Pin
Parwej Ahamad17-Jun-08 4:41
professionalParwej Ahamad17-Jun-08 4:41 
GeneralRe: Remote DataBase Access Pin
ahmedsamir19-Jun-08 0:29
ahmedsamir19-Jun-08 0:29 
Questiontrying out UDP socket, and failing.... (on Vista) [modified] Pin
Super Lloyd17-Jun-08 4:33
Super Lloyd17-Jun-08 4:33 
I think Vista might be the culprit....
Anyway, could anyone share with me how to send some data over UDP and recieve it?
Now it's not working, and I have no clue if it's the sending or recieving or both which fails....

Anyway I have simple code like that:

public void Send(byte[] data, IPEndPoint to)<br />
{<br />
   using (Socket sock = new Socket(to.AddressFamily, SocketType.Dgram, ProtocolType.Udp))<br />
      sock.SendTo(data, SocketFlags.None, to);<br />
}<br />
<br />
<br />
public void Receiving()<br />
{<br />
    byte[] rbuf = new byte[1 << 14];<br />
    using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))<br />
     {<br />
     // [Edit] Solution<br />
     sock.Bind(new IPEndPoint(IPAddress.Any, aPort));<br />
     while (true)<br />
     {<br />
          EndPoint rep = new IPEndPoint(IPAddress.Any, 0);<br />
          int read = sock.ReceiveFrom(rbuf, ref rep);<br />
          Recieved(rbuf, read, rep);<br />
     }<br />
     }<br />
}<br />
void Recieved(byte[] buf, int nRead, EndPoint where)<br />
{<br />
    Console.WriteLine("Recieved {0} byte(s) from {1}", nRead, where);<br />
}


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

modified on Tuesday, June 17, 2008 10:58 AM

AnswerRe: trying out UDP socket, and failing.... (on Vista) Pin
Parwej Ahamad17-Jun-08 4:42
professionalParwej Ahamad17-Jun-08 4:42 
GeneralRe: trying out UDP socket, and failing.... (on Vista) Pin
Super Lloyd17-Jun-08 4:57
Super Lloyd17-Jun-08 4:57 
AnswerRe: trying out UDP socket, and failing.... (on Vista) Pin
Super Lloyd17-Jun-08 4:54
Super Lloyd17-Jun-08 4:54 
QuestionEntity Framework Pin
Brendan Vogt17-Jun-08 4:26
Brendan Vogt17-Jun-08 4:26 
AnswerRe: Entity Framework Pin
Judah Gabriel Himango17-Jun-08 5:16
sponsorJudah Gabriel Himango17-Jun-08 5:16 
GeneralRe: Entity Framework Pin
Brendan Vogt18-Jun-08 3:55
Brendan Vogt18-Jun-08 3:55 
GeneralRe: Entity Framework Pin
Judah Gabriel Himango18-Jun-08 5:43
sponsorJudah Gabriel Himango18-Jun-08 5:43 
QuestionRe: Entity Framework Pin
Brendan Vogt23-Jun-08 3:42
Brendan Vogt23-Jun-08 3:42 
QuestionRetrieving Conrtols custom attribute?? Pin
zachbob17-Jun-08 4:07
zachbob17-Jun-08 4:07 
AnswerRe: Retrieving Conrtols custom attribute?? [modified] Pin
Henrik K. Larsen19-Jun-08 20:37
Henrik K. Larsen19-Jun-08 20:37 
Question[Message Deleted] Pin
imran_rafique17-Jun-08 3:41
imran_rafique17-Jun-08 3:41 
AnswerRe: WebBrowser Control objects Session issue? Pin
Christian Graus17-Jun-08 3:46
protectorChristian Graus17-Jun-08 3:46 
GeneralRe: WebBrowser Control objects Session issue? Pin
imran_rafique17-Jun-08 4:10
imran_rafique17-Jun-08 4:10 
GeneralRe: WebBrowser Control objects Session issue? Pin
Pete O'Hanlon17-Jun-08 4:55
mvePete O'Hanlon17-Jun-08 4:55 
Questionconvert long-&gt;p[][] Pin
cst_kvp17-Jun-08 2:02
cst_kvp17-Jun-08 2:02 
AnswerRe: convert long-&gt;p[][] Pin
Christian Graus17-Jun-08 2:02
protectorChristian Graus17-Jun-08 2:02 
GeneralRe: convert long-&gt;p[][] Pin
cst_kvp17-Jun-08 2:10
cst_kvp17-Jun-08 2:10 

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.