Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!