GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cpp_socket_server/server_socket.cpp at master · AsenOsen/cpp_socket_server

Expand file tree

/

server_socket.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
36 lines (30 loc) · 845 Bytes
/

server_socket.cpp

Copy path

File metadata and controls

executable file
·
36 lines (30 loc) · 845 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "server_socket.h"
SocketServer::SocketServer(unsigned short port)
{
/* Creating row socket */
server = socket(AF_INET, SOCK_STREAM, 0);
if(server < 0)
printf("Socket error: %08x", errno);
/* Binding port to socket */
sockaddr_in server_address;
server_address.sin_family = AF_INET;
server_address.sin_port = htons(port);
server_address.sin_addr.s_addr = INADDR_ANY;
int bindingResult =
bind(server, (sockaddr*) &server_address, sizeof(server_address));
if(bindingResult < 0)
printf("Binding error: %08x", errno);
/* Start listening */
listen(server, 5);
}
Socket SocketServer::Accept()
{
/* Accepting client conenction */
socklen_t addrlen = sizeof(last_client_info);
Socket client = accept(server, (sockaddr*) &last_client_info, &addrlen);
return client;
}
void SocketServer::Shutdown()
{
close(server);
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.