On Wed, 2 Sep 2015 01:48:51 -0700 (PDT) firstname.lastname@example.org wrote:
I have an assignment in my university, i need to listen to an ip:port
and a hardware will send a packet and the server needs to answer to
the hardware , but i dont know how to start.
I have seen some examples but only like an http server but dont know
how to read packets and response.
Well, I do understand that it's easy to find once you know the answer,
but really you had to google for "golang+chat+server" -- because
writing a simple chat server is the sort of "hello world" example for
socket-based networking applications.
So consider just googling for what I proposed  and study those
examples whith appear to use TCP (no websockets and other web-y stuff).
Among the results brought by that search query,  looks like a good
example to start looking at. See below for why I mentioned TCP.
Listen to an IP:PORT
Hmm, you should elaborate (for yourself) on this point: you can't just
"listen on IP:PORT" because IP has no concept of "a port" -- it only
knows about addresses and is able to deliver packets between them.
Ports are property of some higher-level protocols which use IP as their
transport layer. TCP and UDP are the two most widely used examples of
them. So you have to make sure what protocol above IP you're supposed
to use before you start [*].
A hardware will send a data packet with this ifo:
The server will answer this:
Please help me to create the code to listen and answer that data.
Thanks in advance.
Look at , in particular, its sections titled "Socket-level
Programming" and "Data Serialization".
Please also note that asking for help right away without showing any
prior reseach performed by you is a bad behaviour which might turn off
quite a lot of people technically able to help. When you have time,
please consider reading  for more insight on this.
[*] Well, in theory, it's possible to work with "raw IP networking",
but I highly doubt you would be assigned a task like this in a
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/d/optout.