elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Se ha detenido la aplicación
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Se ha detenido la aplicación  (Leído 2,055 veces)
Jeezy

Desconectado Desconectado

Mensajes: 66


Ver Perfil
Se ha detenido la aplicación
« en: 31 Agosto 2018, 18:56 pm »

Hola, tengo un problema en mi cliente servidor funciona por sockets y cuando se cierra el servidor se cierra el socket del cliente utilizando el siguiente código
Código:
client.Close();
client.Shutdown(shutdown.Both);

Y cuando se cierra se detiene la aplicación , alguien me podría explicar por que al cerrar la conexion se detiene gracias.


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Se ha detenido la aplicación
« Respuesta #1 en: 31 Agosto 2018, 19:32 pm »

La llamada al método Socket.Shutdown debes efectuarla antes de cerrar el socket...


Citar
The Close method closes the remote host connection and releases all managed and unmanaged resources associated with the Socket. Upon closing, the Connected property is set to false.

For connection-oriented protocols, it is recommended that you call Shutdown before calling the Close method. This ensures that all data is sent and received on the connected socket before it is closed.

Citar
If you need to call Close without first calling Shutdown, you can ensure that data queued for outgoing transmission will be sent by setting the DontLingerSocket option to false and specifying a non-zero time-out interval. Close will then block until this data is sent or until the specified time-out expires. If you set DontLinger to false and specify a zero time-out interval, Close releases the connection and automatically discards outgoing queued data.

Saludos.


En línea

Jeezy

Desconectado Desconectado

Mensajes: 66


Ver Perfil
Re: Se ha detenido la aplicación
« Respuesta #2 en: 1 Septiembre 2018, 02:44 am »

Ya hice lo que me dijiste pero me salta excepcion en el client.shutdown

Cannot access a disposed object.

o nose si estoy en lo correcto que cuando se cierre un cliente tambien tengo que cerrar la conexion desde el servidor o solo desde el cliente
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines