salut,
je suis a la recherche d'un peu d'aide...
je développe en c# et je ve faire marcher un serveur de socket. Le client est mon PDA mais g un probleme avec la classe INVOKE (elle ne prend qu'un parametre alors que sur un client "normal" je pe en mettre 2.
si quelqu'un a une solution je suis preneur
merci d'avance
voila mon code :
public
delegate void AddMessage( string sNewMessage );
public void OnRecievedData( IAsyncResult ar )
{
// Socket was the passed in object
Socket sock = (Socket)ar.AsyncState;
// Check if we got any data
try
{
int nBytesRec = sock.EndReceive( ar );
if( nBytesRec > 0 )
{
// Wrote the data to the List
string sRecieved = Encoding.ASCII.GetString( m_byBuff, 0, nBytesRec );
// WARNING : The following line is NOT thread safe. Invoke is
// listBox1.Items.Add( sRecieved );
Invoke( m_AddMessage,
new string [] { sRecieved}); ///Mon erreur est ici (2 paramètre au lieu d'1voulu)
// If the connection is still usable restablish the callback
SetupRecieveCallback( sock );
}
else
{
// If no data was recieved then the connection is probably dead
Console.WriteLine( "Client {0}, disconnected", sock.RemoteEndPoint );
sock.Shutdown( SocketShutdown.Both );
sock.Close();
}
}
catch( Exception ex )
{
MessageBox.Show(
this + ex.Message + " Unusual error during Recieve!" );
}
}