Click here to Skip to main content
15,908,674 members
Home / Discussions / C#
   

C#

 
AnswerRe: Thoughtpost P2P Pin
Dave Kreskowiak12-Dec-05 6:29
mveDave Kreskowiak12-Dec-05 6:29 
GeneralRe: Thoughtpost P2P Pin
ShimiG12-Dec-05 6:40
ShimiG12-Dec-05 6:40 
GeneralRe: Thoughtpost P2P Pin
Dave Kreskowiak12-Dec-05 10:07
mveDave Kreskowiak12-Dec-05 10:07 
QuestionAn existing connection was forcibly closed by the remote host Pin
Ricardo Mendes12-Dec-05 6:03
Ricardo Mendes12-Dec-05 6:03 
AnswerRe: An existing connection was forcibly closed by the remote host Pin
Jared Parsons12-Dec-05 6:13
Jared Parsons12-Dec-05 6:13 
GeneralRe: An existing connection was forcibly closed by the remote host Pin
Ricardo Mendes12-Dec-05 6:16
Ricardo Mendes12-Dec-05 6:16 
GeneralRe: An existing connection was forcibly closed by the remote host Pin
Jared Parsons12-Dec-05 8:45
Jared Parsons12-Dec-05 8:45 
GeneralRe: An existing connection was forcibly closed by the remote host Pin
Ricardo Mendes13-Dec-05 0:57
Ricardo Mendes13-Dec-05 0:57 
Maybe there is another problem. Look what is happening: I have the following methods:


internal void SendData(Channel channel, byte[] buffer, int offset, int count)
{
if(channel != null && channel.Socket != null && channel.Socket.Connected)
channel.Socket.BeginSend(buffer, offset, count, SocketFlags.None, new AsyncCallback(OnDataSent), channel);
}

private void OnDataSent(IAsyncResult asyncResult)
{
if(asyncResult != null && asyncResult.AsyncState != null)
{
Channel channel = (Channel)asyncResult.AsyncState;
ushort bytesSent = (ushort)channel.Socket.EndSend(asyncResult);
...
}
}

The Channel class is a custom class that holds a reference to a Socket object. First I call the SendData method, that calls the BeginSend method on the Socket object. When the socket ends sending the data, it calls the OnDataSent method. The problem is that when I try to call the EndSend method, the Socket object is null. I don't have any control over it once is the framework that calls the method. When I don't test if the Socket object is a null reference, I get the NullReferenceException. When I test, I get the other exception (the SocketException).

In other words, all the problems reside in the fact that the Socket object is null. Do you have any idea about what could be causing this behaviour? Could the network topology have any influence?

Thanks.
GeneralRe: An existing connection was forcibly closed by the remote host Pin
Jared Parsons13-Dec-05 7:48
Jared Parsons13-Dec-05 7:48 
QuestionDelegates Pin
DELETEUSER12-Dec-05 5:57
DELETEUSER12-Dec-05 5:57 
AnswerRe: Delegates Pin
Roy Heil12-Dec-05 7:15
professionalRoy Heil12-Dec-05 7:15 
AnswerRe: Delegates Pin
Gerben Jongerius12-Dec-05 8:27
Gerben Jongerius12-Dec-05 8:27 
GeneralRe: Delegates Pin
Den2Fly12-Dec-05 10:25
Den2Fly12-Dec-05 10:25 
GeneralRe: Delegates Pin
Gerben Jongerius13-Dec-05 3:55
Gerben Jongerius13-Dec-05 3:55 
GeneralRe: Delegates Pin
Den2Fly14-Dec-05 4:27
Den2Fly14-Dec-05 4:27 
AnswerRe: Delegates Pin
Den2Fly12-Dec-05 18:49
Den2Fly12-Dec-05 18:49 
QuestionRemote MarshalByRef objects lifetimes Pin
Den2Fly12-Dec-05 5:44
Den2Fly12-Dec-05 5:44 
AnswerRe: Remote MarshalByRef objects lifetimes Pin
leppie12-Dec-05 6:16
leppie12-Dec-05 6:16 
GeneralRe: Remote MarshalByRef objects lifetimes Pin
Den2Fly12-Dec-05 9:24
Den2Fly12-Dec-05 9:24 
GeneralRe: Remote MarshalByRef objects lifetimes Pin
leppie12-Dec-05 21:19
leppie12-Dec-05 21:19 
QuestionTelnet Client in C# Pin
itsprinci12-Dec-05 5:19
itsprinci12-Dec-05 5:19 
AnswerRe: Telnet Client in C# Pin
Jared Parsons12-Dec-05 5:33
Jared Parsons12-Dec-05 5:33 
Questioncomponents, compoenet serviced and COM+ Pin
faviochilo12-Dec-05 4:12
faviochilo12-Dec-05 4:12 
Questionasp.net datagrid value grouping Pin
Dpriya12-Dec-05 3:23
Dpriya12-Dec-05 3:23 
AnswerRe: asp.net datagrid value grouping Pin
Drew McGhie12-Dec-05 4:46
Drew McGhie12-Dec-05 4:46 

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.