public tcp_listener(IPEndPoint listen_address, TransporteTCP data) { _a_data = data; _listen_address = listen_address; _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _listener.Bind(_listen_address); _listener.Listen(100); _listener.BeginAccept(_AcceptCallback, _listener); }
private void MainForm_Load(object sender, EventArgs e) { int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]); openFileDialog1.InitialDirectory = ConfigurationManager.AppSettings["firmware_path"]; firmwareBinaryFilename = ConfigurationManager.AppSettings["fota_filename"]; int tcp_timer_tr = Convert.ToInt32(ConfigurationManager.AppSettings["tcp_timer_tr"]); int tcp_timer_trm = Convert.ToInt32(ConfigurationManager.AppSettings["tcp_timer_trm"]); int tcp_timer_tv = Convert.ToInt32(ConfigurationManager.AppSettings["tcp_timer_tv"]); int udp_timer_tr = Convert.ToInt32(ConfigurationManager.AppSettings["udp_timer_tr"]); int udp_timer_trm = Convert.ToInt32(ConfigurationManager.AppSettings["udp_timer_trm"]); int udp_timer_tv = Convert.ToInt32(ConfigurationManager.AppSettings["udp_timer_tv"]); int queue_delay = Convert.ToInt32(ConfigurationManager.AppSettings["queue_delay"]); var listener = new IPEndPoint(IPAddress.Any, port); // aca queda corriendo en background transporteUDP = new TransporteUDP(); ut = new TesterUT { FotaQueueDelay = queue_delay }; Devices.i().RetrieveDevices += MainForm_UpdateDevices; if (udp_timer_tr != 0) { transporteUDP.TimerTR = udp_timer_tr; } if (udp_timer_trm != 0) { transporteUDP.TimerTRM = udp_timer_trm; } if (udp_timer_tv != 0) { transporteUDP.TimerTV = udp_timer_tv; } transporteUDP.UsuarioTransaccion = ut; transporteUDP.AbrirTransporte(listener, 8192, "main_server"); SA.Colas.Colas.i().DefaultUserGroup = "Usuarios"; transporteTCP = new TransporteTCP(); if (tcp_timer_tr != 0) { transporteTCP.TimerTR = tcp_timer_tr; } if (tcp_timer_trm != 0) { transporteTCP.TimerTRM = tcp_timer_trm; } if (tcp_timer_tv != 0) { transporteTCP.TimerTV = tcp_timer_tv; } transporteTCP.UsuarioTransaccion = ut; transporteTCP.AbrirTransporte(listener, 8192, "main_server"); }
private void Camada3() { TransporteTCP tra = new TransporteTCP(pacote); txtExibi.AppendText("CHAMANDO CAMADA DE TRANSPORTE..." + "\r\n\n"); txtExibi.AppendText("\r\n\n"); pacote = tra.Retorno(); txtExibi.AppendText("INFORMAÇÃO ENVIADA: " + pacote.dados + "\r\n" + "FUNÇÃO: " + pacote.camada3 + "\r\n"); txtExibi.AppendText("\r\n\n"); camada3.Visible = true; }