Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net.Sockets;
- using System.Net;
- using System.IO;
- namespace ConsoleApplication4
- {
- class Program
- {
- static Socket doidaco;
- static TcpListener tccp;
- static NetworkStream newton;
- static BinaryReader rr ;
- static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.Yellow;
- try
- {
- Console.WriteLine("Iniciando...");
- IPEndPoint ipp = new IPEndPoint(IPAddress.Parse("192.168.173.1"), 5000);
- tccp=new TcpListener(ipp);
- tccp.Start();
- Console.WriteLine("Conexão TCP iniciada, ip : 127.0.0.1, porta: 4567");
- doidaco = tccp.AcceptSocket();
- newton = new NetworkStream(doidaco);
- rr = new BinaryReader(newton);
- string mensagem="";
- do{
- mensagem = rr.ReadString();
- Console.WriteLine("\nMensagem do cliente: "+mensagem);
- }while(doidaco.Connected);
- }
- catch(Exception e){
- Console.WriteLine("Erro: "+e.Message);
- Console.ReadKey();
- }
- finally
- {
- doidaco.Close();
- rr.Close();
- newton.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement