[RESOLVED] Socket Error need help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] Socket Error need help

  1. #1
    Join Date
    May 2009
    Location
    .NET 3.5/VS 2008
    Posts
    7

    [RESOLVED] Socket Error need help

    Ok so first things first, here is the error i'm getting and then i'll post the code below it where the error happens:

    No overload for method 'EndReceive' takes '0' arguments (CS1501) - C:\Documents and Settings\Administrator\My Documents\SharpDevelop Projects\SPiN\SPiN\MainForm.cs:82,15

    here is the line it highlights:

    Code:
    int iRx = theSockId.thisSocket.EndReceive();
    and here is the entire sub:

    Code:
    public void OnDataReceived(IAsyncResult asyn) {
    			try {
    				SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
    				int iRx = theSockId.thisSocket.EndReceive();
    				char[] chars = new char[iRx + 1];
    				System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
    				int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
    				System.String szData = new System.String(chars);
    				txtLog.AppendText(szData);
    				WaitForData();
    			} catch (ObjectDisposedException ) {
    				txtLog.AppendText("OnDataReceived: Socket has been closed.");
    			} catch (SocketException se) {
    				txtLog.AppendText(se.Message);
    			}
    		}
    here is where this sub is defined to be the handler:

    Code:
    public void WaitForData() {
    			try {
    				if (m_pfnCallback==null) {
    					m_pfnCallback = new AsyncCallback (OnDataReceived);
    				}
    				SocketPacket theSocPkt = new SocketPacket();
    				theSocPkt.thisSocket = m_clientSocket;
    				m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length,SocketFlags.None, m_pfnCallback, theSocPkt);
    			} catch (SocketException se) {
    				txtLog.AppendText(se.Message);
    			}
    		}
    So if anyone knows how to fix this, it would be awesome because i cant figure it out.

  2. #2
    Join Date
    Jul 2007
    Location
    Illinois
    Posts
    517

    Re: Socket Error need help

    Pass the IAsyncResult object you get when the OnDataReceived callback is called to the Socket.EndReceive() function.

    No overload for method 'EndReceive' takes '0' arguments (CS1501) - C:\Documents and Settings\Administrator\My Documents\SharpDevelop Projects\SPiN\SPiN\MainForm.cs:82,15
    Means that there is no function in the Socket class named EndReceive that takes 0 parameters.
    R.I.P. 3.5" Floppy Drives
    "I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein

  3. #3
    Join Date
    May 2009
    Location
    .NET 3.5/VS 2008
    Posts
    7

    Re: Socket Error need help

    Awesome, thanks, will mark as solved.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center