Click here to Skip to main content
15,440,620 members
Home / Discussions / C#
   

C#

 
QuestionCOM exception loss Pin
Member 126326017-Oct-20 20:57
MemberMember 126326017-Oct-20 20:57 
AnswerRe: COM exception loss Pin
Richard MacCutchan7-Oct-20 21:35
mveRichard MacCutchan7-Oct-20 21:35 
GeneralRe: COM exception loss Pin
Member 126326017-Oct-20 22:03
MemberMember 126326017-Oct-20 22:03 
GeneralRe: COM exception loss Pin
Richard MacCutchan7-Oct-20 22:25
mveRichard MacCutchan7-Oct-20 22:25 
GeneralRe: COM exception loss Pin
Member 126326017-Oct-20 22:58
MemberMember 126326017-Oct-20 22:58 
GeneralRe: COM exception loss Pin
Richard MacCutchan7-Oct-20 23:24
mveRichard MacCutchan7-Oct-20 23:24 
AnswerRe: COM exception loss Pin
OriginalGriff8-Oct-20 4:10
mveOriginalGriff8-Oct-20 4:10 
QuestionScanning for servers Pin
pkfox4-Oct-20 21:52
professionalpkfox4-Oct-20 21:52 
Hi all, the code below broadcasts on a lan for Logitech media servers listening on UDP port 3483 - it works perfectly unless I run it more than once in the same session which results in the error Only one usage of each socket address is normally permitted. Now I understand that you can't bind to a socket twice with the same ip/port pairing but I'm not trying to do that - I'm simply resending the broadcast. I don't have servers running on the same machine as this code is run on ( that's bitten me before ) Any ideas ?
C#
public async Task<LMSResponseParser> ScanForServer()
     {
         try
         {
             this.listener = new UdpClient(UDPPort); // This is where it bombs on the second run
             this.ReceiveIP = new IPEndPoint(IPAddress.Broadcast, UDPPort);
             this.Result = await listener.ReceiveAsync();
             // The buffer should contain "eIPAD0\JSON0\UUID0\VERS0" in a byte array
             this.RequestData = this.Result.Buffer;
             this.ReceiveIP = this.Result.RemoteEndPoint;
             // Send the buffer back to initiate a response
             this.BytesSent = await this.listener.SendAsync(this.RequestData, this.RequestData.Length, this.ReceiveIP);

             this.Result = await this.listener.ReceiveAsync();
             // This should contain information about our server ( Port number , IP etc etc )
             this.BytesReceived = this.Result.Buffer;

             if (this.BytesReceived != null && this.BytesReceived.Length > 0)
                 this.RetVal = Encoding.UTF8.GetString(this.BytesReceived);
             // Parse the response and place the values in a dictionary
             this.parseLMSResponse = new LMSResponseParser(BytesReceived);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
         finally
         {
             if (this.listener != null && this.listener.Client.Connected)
                 this.listener.Close();
         }
         return this.parseLMSResponse;
     }
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP


modified 5-Oct-20 5:30am.

AnswerRe: Scanning for servers Pin
Richard Deeming5-Oct-20 2:44
mveRichard Deeming5-Oct-20 2:44 
GeneralRe: Scanning for servers Pin
pkfox5-Oct-20 3:44
professionalpkfox5-Oct-20 3:44 
GeneralRe: Scanning for servers Pin
pkfox5-Oct-20 4:17
professionalpkfox5-Oct-20 4:17 
Questionversion mismatch Pin
Member 149246074-Oct-20 9:30
MemberMember 149246074-Oct-20 9:30 
AnswerRe: version mismatch Pin
Richard Deeming5-Oct-20 2:33
mveRichard Deeming5-Oct-20 2:33 
GeneralRe: version mismatch Pin
Member 149246075-Oct-20 7:45
MemberMember 149246075-Oct-20 7:45 
GeneralRe: version mismatch Pin
Richard Deeming5-Oct-20 21:22
mveRichard Deeming5-Oct-20 21:22 
QuestionprintDocument Pin
Member 149437371-Oct-20 19:02
MemberMember 149437371-Oct-20 19:02 
AnswerRe: printDocument Pin
Gerry Schmitz1-Oct-20 19:11
mveGerry Schmitz1-Oct-20 19:11 
GeneralRe: printDocument Pin
Member 149437371-Oct-20 22:54
MemberMember 149437371-Oct-20 22:54 
AnswerRe: printDocument Pin
OriginalGriff1-Oct-20 20:03
mveOriginalGriff1-Oct-20 20:03 
GeneralRe: printDocument Pin
Member 149437371-Oct-20 22:37
MemberMember 149437371-Oct-20 22:37 
GeneralRe: printDocument Pin
OriginalGriff1-Oct-20 22:40
mveOriginalGriff1-Oct-20 22:40 
QuestionHow to compare on DPFP.Template to another DPFP.Template Pin
Member 144684061-Oct-20 3:07
MemberMember 144684061-Oct-20 3:07 
AnswerRe: How to compare on DPFP.Template to another DPFP.Template Pin
Gerry Schmitz1-Oct-20 4:49
mveGerry Schmitz1-Oct-20 4:49 
GeneralRe: How to compare on DPFP.Template to another DPFP.Template Pin
Member 144684061-Oct-20 8:39
MemberMember 144684061-Oct-20 8:39 
GeneralRe: How to compare on DPFP.Template to another DPFP.Template Pin
Gerry Schmitz2-Oct-20 4:31
mveGerry Schmitz2-Oct-20 4:31 

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.