Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
Send TCP type message using WCF

I am trying to send a tcp message to a gprs server. I was trying to do it through WCF, however, I always see tutorials or information regarding the consumption of services, however, there is no service to consume. It is simply sending a tcp-type message to a server using WCF. I have the port, and the server for the connection. How could I do it? I need to create the WCF client for sending messages, but I don't know how without services.

I am using visual studio and c # language

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I am trying to send a tcp message to a gprs server. I was trying to do it through WCF

Since the remote server is not a SOAP service but simply a server exposing a TCP port you should use TCP APIs rather than WCF. The reason being that message content and protocol will be different. WCF uses SOAP messages which generally are sent as XML text as opposed to TCP which is binary. Now you could configure WCF to serialize as binary but the result will still be different. There are alot more differences to TCP vs WCF which I won't go into here.

Use the following TCP example:

TcpClient client = new TcpClient("localhost", 80); //enter your server ip and port

// Translate the passed message into ASCII and store it as a Byte array

Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);

// Get the stream for writing

NetworkStream stream = client.GetStream();

// Send the message to the connected TcpServer.

stream.Write(data, 0, data.Length);

//Close everything to avoid memory leaks

stream.Close();
client.Close();
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda