If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: simple client server app

Well, that's part of the problem.

I KNOW that the code presented works, but what it does, I do not know.

I've tried to run both the client and server program, but cannot see the results. I'm using Visual Studio 2010 and when I run (debug) the program, it flies through some stuff, a screen appears and disappears and that's it.
When I put a break at the end of the program, it doesn't stop the program.

I guess, I'm really looking for a starting block. Do I need breaks in a different location?
Am I supposed to "step" through the program.

Re: simple client server app

Originally Posted by tmcfadden

Well, that's part of the problem.

I KNOW that the code presented works, but what it does, I do not know.

I've tried to run both the client and server program, but cannot see the results. I'm using Visual Studio 2010 and when I run (debug) the program, it flies through some stuff, a screen appears and disappears and that's it.

That is because you are not stepping into the program with F10.

When I put a break at the end of the program, it doesn't stop the program.

Why are you putting a break at the end of the program? You're supposed to place a breakpoint at the beginning of the main() function, since that is where the C++ program starts from. Or hit F10 to single-step through the program.

Re: simple client server app

I've stepped through both the server and client programs with F10 (both of which I provided earlier).

What happens is that my instructor has created both programs, but each only confirms the number of arguments and outputs the following:
SERVER PROGRAM

Syntax: Timesrvr PortNumber

CLIENT PROGRAM

Syntax: Timeclnt ServerName PortNumber

We're supposed to pass arguments that tell the server to use a port (example 2000)
Then we need to pass arguments to the client that tell it to connect to the server at ip 127.0.0.1 port 2000

So first I have to pass the arguments into the program. I know one way to do is in the file CONFIGURATION PROPERTIES | DEBUGGING | COMMAND ARGUMENTS in VB Studio 2010.
So when I enter those arguments and run the program, the ARGC DOES, indeed, count up to the amount of arguments that I entered. However, those values are never output to screen.
I didn't think I needed to create a variable to hold them though. I know the section of code that calls this up is here:

Re: simple client server app

This part of code means:

the program "Timeclnt" (obviously, the name of your client application) does expect from you to pass in exactly two command line arguments for the ServerName (IP address or pc-name) and socket port number.

which, as you can see, basically just outputs "Timeclint ServerName PortNumber"

Do you know what "argc" is supposed to be, and more importantly, what it means? What is the argument count (argc) value when you get to that line of code? It obviously isn't 3, so you need to figure out what are the command-line arguments and exactly the number of arguments that need to be passed to the program.

Re: simple client server app

right. That much I know. In fact, BOTH programs want me to pass arguments.
The server side wants to know what port I'll be using.
The client side wants to know the ip address of the server, as well as the port.

The question is, how do I input those arguments into the code??
So, the quick answer to your question is that I haven't passed any arguments into the program. I've tried, but I'm not seeing them.

Re: simple client server app

Have you compiled both programs successfully? To check that they are working:

Open a console. Assuming the program for the server has been compiled to a program called server.exe. Make sure the console is at the folder where server.exe is located. Type server 2345 (where 2345 is the port number to use. Use the required port number). You should see something like

Server [mycomp] waiting on port 2345

where [...] will contain the name of your computer.

Open another console. Assuming the client program has been compiled to a program called client.exe. Make sure the console is at the folder where this program is located. Type client <comp> 2345 where <comp> is the name of the computer shown from the server command above in the [] but not including the [] and 2345 is the port number used with the server command. You should see something like

Re: simple client server app

Hey 2kaud,
As always, thanks for your valued input. You've instantly made this more clear.
To answer your questions.
- Yes - I ran both programs, but they're not "designed" to work initially. The point of the assignment is to make each program do just what you said it would do.

- If you run the server.exe from the console as it is now, it returns this:

Syntax: Timesrvr PortNumber

- If you run the client.exe from the console as it is now, it returns this:

Syntax: UDPTimeClient PortNumber

So I have to add code snipits to the existing code to force the port number on the server, AND add the ipaddress and the port number to connect to on the client.

So the question is, can I simply do this by entering arguments in the respective programs, or do I have to edit the code in some way?

Re: simple client server app

Yes - I ran both programs, but they're not "designed" to work initially. The point of the assignment is to make each program do just what you said it would do.

I took your code and compiled it as you had posted it to produce two programs server.exe and client.exe. They work as I outlined in post #11. Just type server 2345 from the console. You must specify a port number (2345 in my example) following server

d:\MyProgs>server 2345

Server [mycomp] waiting on port 2345

Then from another console prompt just type client mycomp 2345 (where mycomp is the name of the computer retured from server and 2345 is the same port number used with server