Click here to Skip to main content
15,892,768 members
Home / Discussions / C#
   

C#

 
QuestionInterfaces & Objects Pin
adafaaa12-Dec-05 9:48
adafaaa12-Dec-05 9:48 
AnswerRe: Interfaces & Objects Pin
Colin Angus Mackay12-Dec-05 11:15
Colin Angus Mackay12-Dec-05 11:15 
QuestionImplementing cut, copy, paste, undo, select all Pin
monrobot1312-Dec-05 9:01
monrobot1312-Dec-05 9:01 
AnswerRe: Implementing cut, copy, paste, undo, select all Pin
Polis Pilavas12-Dec-05 11:26
Polis Pilavas12-Dec-05 11:26 
Questionpassing parameters to a DLL function receiving pointer Pin
devinzhang12-Dec-05 8:27
devinzhang12-Dec-05 8:27 
AnswerRe: passing parameters to a DLL function receiving pointer Pin
Colin Angus Mackay12-Dec-05 9:33
Colin Angus Mackay12-Dec-05 9:33 
AnswerRe: passing parameters to a DLL function receiving pointer Pin
Colin Angus Mackay12-Dec-05 9:35
Colin Angus Mackay12-Dec-05 9:35 
GeneralRe: passing parameters to a DLL function receiving pointer Pin
devinzhang12-Dec-05 9:58
devinzhang12-Dec-05 9:58 
AnswerRe: passing parameters to a DLL function receiving pointer Pin
Jared Parsons12-Dec-05 11:40
Jared Parsons12-Dec-05 11:40 
GeneralRe: passing parameters to a DLL function receiving pointer Pin
devinzhang12-Dec-05 12:08
devinzhang12-Dec-05 12:08 
QuestionSigning CodeDom assemblies Pin
cbadal12-Dec-05 8:00
cbadal12-Dec-05 8:00 
AnswerRe: Signing CodeDom assemblies Pin
cbadal14-Dec-05 7:08
cbadal14-Dec-05 7:08 
QuestionDatagrid ghost selection Pin
Glenn E. Lanier II12-Dec-05 6:29
Glenn E. Lanier II12-Dec-05 6:29 
QuestionUDP port not receiving any data Pin
MullahOmer12-Dec-05 6:14
MullahOmer12-Dec-05 6:14 
AnswerRe: UDP port not receiving any data Pin
mcljava12-Dec-05 7:44
mcljava12-Dec-05 7:44 
QuestionThoughtpost P2P Pin
ShimiG12-Dec-05 6:07
ShimiG12-Dec-05 6:07 
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 

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.