Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:51:24+00:00 2026-05-25T12:51:24+00:00

I want to write a simple client that sends a message to a server

  • 0

I want to write a simple client that sends a message to a server and receives a response. I’ve got a server that broadcasts the same message to all connected clients and its working when I’m testing it with telnet. When I try doing it using the Erlang shell, gen_tcp:send wont send any messages until I’ve close the socket.

This is what I’m trying to do:

{ok, S} = gen_tcp:connect(IP, Port, []).
gen_tcp:send(S, "Test").
flush().

I can see that the message gets sent when I close the socket by looking at my telnet client.

Erlang version:R14B01 (erts-5.8.2)

Update

hdima commented and said that it might be wrong with how the server extract the messages from the stream. This seems to be the case cause when I tried writing my own server the client seems to work as expected. I’ll try to get the source code of the server. The server is written in Java btw.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:51:24+00:00Added an answer on May 25, 2026 at 12:51 pm

    The main problem is that there is no Universal Message Format. So your first step is to find what message format the server using. You can’t speak with the server on a different language.

    Some message formats can be:

    • The whole stream is a message.
    • Fixed size messages.
    • Messages delimited by a marker. For example SMTP, POP, HTTP and many other protocols use this type of messages.
    • Messages with a size field. For example TLV (Type-Length-Value) message format. IP, UDP, Erlang and many other protocols use this type of messages.

    For example if the server understand messages delimited by the line feed character you can send two distinct messages with the following code:

    1> {ok, S} = gen_tcp:connect(IP, Port, []).
    2> gen_tcp:send(S, "Test\n").
    3> gen_tcp:send(S, "Test2\n").
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a simple SMPP Server that basically forwards traffic to another
I want to write a simple server application that will take commands from a
I want to write a Simple P2P RDP Client and Server in Python. This
I want to write a simple chat-client in Ruby for the terminal. The Problem
I want to write a simple class (PHP5) that can 'run' an unknown amount
I want to realize a simple client-server connection using Nodejs. But I've encountered with
I am new to raw socket. I want write a server and a client
I have two simple programmes, server and client, both at localhost. What I want
I want to write a simple, dumb, X terminal emulator in C on a
I want to write a simple web framework myself using WSGI, Python. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.