Instant messenger app help

This is a discussion on Instant messenger app help within the C Programming forums, part of the General Programming Boards category; I was hoping someone could assist me on a text-based instant messaging client(using UDP) I am working on. I have ...

Instant messenger app help

I was hoping someone could assist me on a text-based instant messaging client(using UDP) I am working on. I have the network communication basics already in place but, specifically, needed some further help on a "getting a user list" function. Eventually, I will get a "send message to user" function going, but I just wanted to get the user list working for now. The server code that the client will communicate with is not available to me, but I will list the implementation details below. Any help or advice on how to recieve a user list from the server would be greatly appreciated.

Sequence Number: Used to match requests and replies between client and server. In other words, a request’s corresponding reply will have the same sequence number. The client should increment the sequence number (by one) with each new request.

From User Name: Client user name

Optional Parameter: Number of user names in a user list

Optional Data: List of user names

Implementation Details:
Here is an example sequence of events:

1. The client will prompt for a user name.
2. The client will issue a login request to the server, and receive a reply from the server.
3. Upon a successful login, the client will use the select() call and wait for input from:
a. User input (file descriptor 0)

i. Upon receiving user input, the client will determine if the user
wants to request a user list.

ii. If the user asks for a user list, the client will send a user list request
packet to the server, and display the response.

4. If the user chooses to quit, a logout request is sent to the server, and the client exits.
5. Repeat steps 3-4

Here is a rough go at the client code I have come up with so far. I have bolded the "user list" area.

Well the first thing is to figure out that functions can contain more than printf statements. Your main() is already over 200 lines long, and you've barely started on the code.

Like for example, separate functions for all the sending stuff, and receiving stuff
Separate functions to create / disassemble each packet type.

Get lots of paper, and start sketching out all the things you need to do and try and organise those things into something more coherent. Because your code has all the hallmarks of a sit down and start hacking approach.

> instant messaging client(using UDP)
But UDP is insecure - packets may be dropped and you'll never find out.