Sockets....

This is a discussion on Sockets.... within the Networking/Device Communication forums, part of the General Programming Boards category; Hi All,
I am having trouble with Beej's Guide to Network programming. I understand the tutorial but...
I have (tried) ...

How many threads can one have? I have a max thread count at 25 at the moment.

Can you terminate a thread from within the source thread it self? e.g When the client exits, my server program catches that and exist the client thread loop. Can i use closehandle after i break out of the thread loop and before the thread function pointer exist? Right now close all threads before server exit. I just loop and close on the thread counter.

I need to find a better way using the client threads as since i am closing all threads at server exit the thread counter (for clients) at 25 wont last long.

Internet

Yep, and i got a lot more

But what i have done so far seems to work pretty good. But could you answer this.

Does this work over the internet. e.g. if i connect to the internet
with my modem. I then get the internet ip address (check my dial up connection, client id) and use that in my server app. I then get someone on the net to run my client program (connecting with the ip i am using). Will it work?

I guess what i am trying to find out is:
When binding a socket to an ip, what does the function do? Check threw a current internet connection, local networkcards etc.

If so, is there a function to check for a internet connection and if so get the internet address you are connected with?

Well, all I really meant was for you to code it and test it locally, then try to use a net based connection. As long as you're bound on an interface that is connected to the net, you should do OK. Check out beej's for INADDR_ANY.

Yep

Yep, will do. It all works locally. And i have also tried locally using the internet address i get when i connect to the internet. That work to. So i guess the next test is to send the client to a friend and test it remotly...... That will be pretty cool if it works....

Just make sure you're code is secure. There are plenty of buffer overflow bugs that leave servers exposed to attack. I'm sure you'll be safe, and no-one will target you, but it's good practice to write safe code.

Overflow?

hmmmm, that dosnt sound cool at all Buffer overflows? I am currently reading in the tutorial about writing read/write functions that ensures all data is sent and recieved. e.g. loop on send/recieve until you get all the bytes you should get (as descriped in a packet struct). Is that what you mean? (I am not familiar with the terms yet). I will eventually encrypt the data being sent but that far off yet...Could you give a specific example on buffer overflow and online targeting etc...(in general terms etc)

they could put more than 25 characters in it. (Unless you use a safer method of input, such as fgets). When an array is overflowed, they can overwrite the code of the program with their own machine language instructions*, causing the program to do whatever they want.

If it is possible to overflow an array remotely, it can be disasterous. The blaster worm is an example of this.

* The only thing overwritten normally is the return address for a function, and when the program returns, it returns to the beginning code you have entered into the overflowed array (on the stack). That is why if you overflow an array normally, the program will crash, because the return address will be invalidated.