Click here to Skip to main content
15,921,941 members
Home / Discussions / C#
   

C#

 
QuestionI tried tht earlier and i gott this error "Patient cannot implement interface member System.IComparable.CompareTo(Object)" Pin
ADTC#29-Apr-08 3:02
ADTC#29-Apr-08 3:02 
AnswerRe: I tried tht earlier and i gott this error "Patient cannot implement interface member System.IComparable.CompareTo(Object)" Pin
J a a n s29-Apr-08 3:06
professionalJ a a n s29-Apr-08 3:06 
Generalyet another one cropped up Pin
ADTC#29-Apr-08 3:14
ADTC#29-Apr-08 3:14 
GeneralRe: yet another one cropped up Pin
J a a n s29-Apr-08 3:28
professionalJ a a n s29-Apr-08 3:28 
GeneralThank you Pin
ADTC#29-Apr-08 4:30
ADTC#29-Apr-08 4:30 
AnswerRe: The best overload method match system.IComparable has invalid arguments Pin
J a a n s29-Apr-08 2:54
professionalJ a a n s29-Apr-08 2:54 
QuestionDoesnot implement interface member System.IComparable.CompareTo(Object) Pin
ADTC#29-Apr-08 3:06
ADTC#29-Apr-08 3:06 
AnswerRe: Doesnot implement interface member System.IComparable.CompareTo(Object) Pin
J a a n s29-Apr-08 3:09
professionalJ a a n s29-Apr-08 3:09 
Questionyet another one cropped up Pin
ADTC#29-Apr-08 3:19
ADTC#29-Apr-08 3:19 
GeneralInstallation Pin
coders_need29-Apr-08 1:14
coders_need29-Apr-08 1:14 
GeneralRe: Installation Pin
J a a n s29-Apr-08 1:25
professionalJ a a n s29-Apr-08 1:25 
GeneralRe: Installation Pin
Vikram A Punathambekar29-Apr-08 2:17
Vikram A Punathambekar29-Apr-08 2:17 
QuestionHow to use regular expression Pin
Exelioindia29-Apr-08 0:07
Exelioindia29-Apr-08 0:07 
AnswerRe: How to use regular expression Pin
c242329-Apr-08 0:48
c242329-Apr-08 0:48 
GeneralRe: How to use regular expression Pin
Exelioindia29-Apr-08 1:05
Exelioindia29-Apr-08 1:05 
AnswerRe: How to use regular expression Pin
Pete O'Hanlon29-Apr-08 0:51
mvePete O'Hanlon29-Apr-08 0:51 
GeneralRe: How to use regular expression Pin
Exelioindia29-Apr-08 1:03
Exelioindia29-Apr-08 1:03 
GeneralTCP Socket Exception , two ports / one IP address Pin
Rick van Woudenberg28-Apr-08 23:40
Rick van Woudenberg28-Apr-08 23:40 
Dear all,

I'm trying to bind two ports to one IP address. In my first method I bind a port ( 31010 ) to IpAddress.Any

                Int32 port = 31010;<br />
                IPAddress localAddr = IPAddress.Any;<br />
                //TcpListener server = new TcpListener(port);<br />
                server = new TcpListener(localAddr, port);<br />
                server.ExclusiveAddressUse = false;<br />
                // Start listening for client requests.<br />
                server.Start();<br />
<br />
                // Buffer for reading data<br />
                Byte[] bytes = new Byte[256];<br />
                String data = null;<br />
<br />
                // Enter the listening loop.<br />
                while (true)<br />
                {<br />
                    // Perform a blocking call to accept requests.<br />
                    // You could also user server.AcceptSocket() here.<br />
                    client = server.AcceptTcpClient();<br />
                    client.ExclusiveAddressUse = false;<br />
                    //blah blah the rest ... <snip><br />
<br />
                }</snip>



This works fine in itself. The application is listening on this port and receives data which is processed happily.

However, I add another method to bind another port ( 31009 ) which I call after the first one :

        private static void SendMessageToMessenger(string data)<br />
        {<br />
            //create the socket instance...<br />
            mm_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
<br />
            // get the remote IP address...<br />
            IPAddress ip = IPAddress.Any;<br />
            mm_socClient.ExclusiveAddressUse = false;<br />
            int iPortNo = 31009;<br />
            //create the end point <br />
            IPEndPoint ipEnd = new IPEndPoint(ip.Address, iPortNo);<br />
            //connect to the remote host...<br />
            mm_socClient.Connect(ipEnd);<br />
<br />
            Object objData = data;<br />
            byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());<br />
            mm_socClient.Send(byData);<br />
<br />
            // End string<br />
<br />
            mm_socClient.Disconnect(true);<br />
        }


And then it goes wrong. It throws an Exception saying :

SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted

I know that the first method is performing a blocking call to receive data, but I'm assuming this blocking call is done for the port and not the IP address but I could be wrong there. Anyhow, it won't allow me to bind a different port to the same IP address, although I set the ExclusiveAddressUse to false.

Can anyone help me out here ?

Cheers,
GeneralRe: TCP Socket Exception , two ports / one IP address Pin
Bert delaVega29-Apr-08 5:07
Bert delaVega29-Apr-08 5:07 
GeneralNumericUpDown control in ToolStrip Pin
mcbass28-Apr-08 23:00
mcbass28-Apr-08 23:00 
GeneralRe: NumericUpDown control in ToolStrip Pin
John_Adams29-Apr-08 1:04
John_Adams29-Apr-08 1:04 
GeneralRe: NumericUpDown control in ToolStrip Pin
mcbass29-Apr-08 2:28
mcbass29-Apr-08 2:28 
GeneralRe: NumericUpDown control in ToolStrip Pin
PubLee23-Jan-10 0:16
PubLee23-Jan-10 0:16 
GeneralRunning code in a different appdomain Pin
laserbaronen28-Apr-08 22:59
laserbaronen28-Apr-08 22:59 
GeneralRe: Running code in a different appdomain Pin
Simon P Stevens28-Apr-08 23:27
Simon P Stevens28-Apr-08 23:27 

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.