Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/System.hpp>
- #include <iostream>
- #include <process.h>
- #include <conio.h>
- #include <Winsock2.h>
- #include "err_enums.h"
- #define DEBUG
- #include "lib.h"
- #define PORT 8118
- #define MAX 16
- /*
- some foresight for myself: is it really "safe"
- to find new connections on the same port that
- i will be using to communicate with the clients
- in other threads? will the protocol difference
- prove to work in my favour for once?
- at least if it is an issue, it won't affect the
- client, because it only uses one protocol at a
- time (and doesn't need to handle multiple servers
- at one time). not that it makes a big difference,
- a client without a functioning server is about as
- useful as a brick.
- actually, the brick is more useful. at least it
- was surfaced as to where it could be used for
- construction, and has value.
- does a programme have value? if i've learned an-
- ything about software, it certainly does; and it
- isn't exactly cheap, either. but that is only in
- the case of which the programme is functional and
- is useful. so does a nonfunctioning programme even
- have a value?
- well, in theory, a programme's value can be deter-
- mines by taking how long it took to make it and
- taking that in proportion to it's usefulness. so,
- if these two values are proportional, does this
- mean that, despite the time it takes to make the
- programme, if it is nonfunctional, it is without
- value? can there exist something without value?
- then again, no one's going to pay for a programme
- that doesn't even compile, or has runtime errors.
- so i suppose a programme's worth cannot be deter-
- mined by these values alone.
- so, because everything at least has some sort of
- value and a nonfunctional programme does not, we
- can come to the conclusion that there exists na-
- ught to which has a lesser value than a nonfunc-
- tional programme.
- what the hell am i even doing this isn't an essay
- alec get back to work god damnit
- */
- struct User {
- char *username;
- char *ip;
- long long x, y;
- };
- void hClient(void *params); // client handle
- void careAboutTheUser(void *params); // gets input from cmd line in new thread
- int main() {
- SOCKADDR_IN saddr;
- SOCKET s;
- WSADATA w;
- if(WSAStartup(MAKEWORD(2,2), &w) != 0)
- return FAILSTRT;
- s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if(s == INVALID_SOCKET) {
- WSACleanup();
- return COULD_NOT_SOCKET_CORRECTLY;
- }
- saddr.sin_family = AF_INET;
- saddr.sin_port = htons(PORT);
- saddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
- if(bind(s, (SOCKADDR *)&saddr, sizeof(saddr)) == SOCKET_ERROR) {
- closesocket(s);
- WSACleanup();
- return FAILBIND;
- }
- if(listen(s, 5) == SOCKET_ERROR) {
- closesocket(s);
- WSACleanup();
- return FAILLSTN;
- }
- while(true) {
- }
- return OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement