#networking #sockets #tcpip #cplusplus
That is an introduction to community programming by constructing a server that echos the shopper’s messages again once more. The server is penned in C++.
Get it functioning in LINUX: https://www.youtube.com/watch?v=cNdlrbZSkyQ&attribute=youtu.be
In the event you is perhaps wanting for a backgrounder on networking, sockets, ports and lots of others. Study out the companion video clip beneath: https://youtu.be/TE1XQ8U_JNA
It’s your decision PuTTY to check out the server. It may be downloaded from right here: http://www.chiark.greenend.org.united kingdom/~sgtatham/putty/most present.html
Full useful resource will be downloaded right here: https://bitbucket.org/sloankelly/youtube-source-repository/src/learn/cpp/networking/BarebonesClient/
resource
For people with error "invalid padding length" instead of using SSH in puty, use RAW.
The amounts of stuff you can learn through youtube! Thank you
I'm having issues with getting the server to work.
I copied the code from the bitbucket and upon running it I received error 10061 "WSAECONNREFUSED".
Then I tried it with hint.sin_addr.S_un.S_addr = INADDR_ANY; instead of inet_pton(AF_INET, ipAddress.c_str(), &hint.sin_addr); and this time I received error 10049 "WSAEADDRNOTAVAIL".
I also tried changing the ipAddress to "192.168.0.1" and got error 10061 again.
I'm new to network programming and it's probably a mistake on my part. Please help.
This was a great introduction to sockets programming for me.
Does it matter what port number you input into the htons() around 11:40? He does not specify where this value comes from and I am wondering if it is arbitrary. Spent many hours before trying to build a server using ASIO and I think the port number matter? With ASIO I tried using port numbers attached to my local ip address through the command prompt and it did not seem to run implement or connect to the server. I probably did something wrong, but hey. Thanks in advanced
Hey guys!!!
If u r having problems with the inet_ntop function, i have the solution.
#define WIN32_WINT _WIN32_WINT_WIN8
You can search it if u want.
Plz, pinne this comment to help other people.
inet_ntop not defined, why?
thank you Sloan, I used VS2019 and it works, great tutorial Sir! thank you
inet_ntop was not declared in this scope
How to create this local host?
Hello sir,
I have tried this code.
And through putty when I am connecting local host afterthat I am not able to type something in putty
What I can do for it ?
i just got putty connection refused and decided to use telnet and it still works lol
Didn't anyone face this error?
error: 'inet_ntop' was not declared in this scope.
Kindly help someone
I always receive 204.204.204.204, which seems error in recv() function. The first time I try, it was successful, but now it always shows I have connected in 204.204.204.204.what can I do?
people want to know what i can do with this server ? how can i know for sure it wont get hacked ?
C ++ is a difficult language and it is not very difficult to learn a language like this in almost every field, you need to know the functions by heart.
Очень помог, спасибо огромное!
Clients from another ip cannot connect to the server, why?
I get a "Can't connect to server, Err #10061" after copying and pasting the source code.
If you're using a different ide (Im using vscode) and you're getting an error about "inet_ntop was not declared" you may need to define _WIN32_WINNT so the compiler knows what system you're compiling for.
I'm on windows 10 so adding "#define _WIN32_WINNT _WIN32_WINNT_WIN10" above all my code fixed the problem for me. More info here: https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers?redirectedfrom=MSDN#setting-winver-or-_win32_winnt
If using gcc you may also need the flag "g++ server.c -o server -lws2_32"
I triend that in Dev c++ but im getting error. [Error] 'inet_ntop' was not declared in this scope
is it about linkage ? how can i fix?
What if I want to send object data instead of a char?
In most applications I just send an object like for example in a game an enemyVO that then tells me the location, current sprite, animation,… all that stuff that can't be contained in char data
sorry im korean so im not used to be using english
i just start socket programming
so am i create two project server project and client project?
14:42 7FFFFFFF = ((16^7)*8)-1 = ((16^8)/2)-1 = (1<<31)-1 = (2^31)-1 = 2147483647, otherwise known as INT_MAX, the largest prime number within the signed int32 range. 🙂
wouldn't it make sense to use some framework instead of writing from ground up and creating sockets, handling streams/buffer, and lots of things low level things like that.
I am getting errors: getnameinfo and inet_ntop is undefined?? Why is this? I am importing ws2tcpip.h. Is it because they are obsolete now?
arph/inet not founding . How can i solve it ?
Hi Sloan Kelly. Thanks for the tutorial you provided. I do have some questions though regarding the echo part. How does the client side interpret the bytes which are echoed to it? Is there an inbuilt function which readily converts the bytes of data to a string?
Very good tutorial! Thanks a lot
Thank you very much for explaining this!
For those getting the error Can't connect to server code 10061. The repository link above is to the client. You'll have to find the correct bare bones server project.
I am getting an error of "invalid padding length on received packets" in putty while opening the client with 127.0.0.1 and 54000
Thank god it work
Big Like, keep on please
Great resource, except for changing putty from ssh to raw, everything worked great! Thanks so much for the video.
getnameinfo() and inet_ntop() functions not recognized. Can anyone help?
Thanks for the time and effort put in this video. It is very informative.
Hi Sloan thank you for this video. I have an issue with wsOk value , can you help me please?
'inet_ntop' was not declared in this scope? How do I fix that? I am using Code::Blocks MinGW64 Windows 7.
doors are overrated
Putty failed the first time because you had SSH selected instead of raw.
IF YOU HAD MANY PROBLEMS TO COMPILE PLZ COPY AND PASTE THIS CODE IN YOUR HEAD.h file
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")
int main() {
return 0;
}
Sloan your application is great! How can I change the mode from blocking to non-blocking socket?
Well this is quite the step-up from Python.. 😛
Why is clientSize a pointer? Is it possibly modified in any way when the connection is accepted?
hello. i have problem!
when i click Local Windows Debugger, it start 2s then close.thanks
It worked! Thank you!