Jump to content

Creating echo server and starting it with cmd?

Mariius

So, I have an assignment to create echo server / client program (for example ATM machine model) and run it in echo loop, which means that I need to start server from command line (use some sort of port for server and then make sure that Client software uses the same port so two programs can communicate). The problem is that I don't know the following:
how to start server from command line and run program on specific port and then run another one on that port aswell?
how to at least compile the code? I have an example code (in c) (but I am unable to show it because of University rules), but what I can say is that, it uses the following:
#ifdef _WIN32
#include <winsock2.h>
#define socklen_t int
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Anyone has any idea how to compile it? I mean, I tried to with gcc (dev c++), but no luck... And how to start the bloody server??

Link to comment
Share on other sites

Link to post
Share on other sites

It is very simple on Linux. I dont know about windows, though.

 

 

gcc server.c -O server                      Compiles your Server.c file and outputs the binary into a file called "server"

./server                                             Starts the server binary that you just output from gcc.

 

 

I can help you in PM if you dont want to pos tthe code here.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×