Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/overhertz/domains/ on line 13
code:zIRON - Get the latest releases plus source-codes and tutorials - Simplifed Assembly Programming Language.
Register | Login
Forum Index > Samples > Simple Winsock Message Server
Author Message
Pages: 1
Site Admin


(send private message)

Posts: 927
Topics: 54

OverHertz Studio
[8] Simple Winsock Message Server - posted: 2011-05-05 16:34:18
This small sample console application acts as a simple message server, if you connect to port 1111 with telnet you will receive the message "Hello World!" and then be disconnected. Very simple, useful to play around with.

program WIN32CUI 'Sample';

#include 'ziron32.zir';
#include 'smm32.zir';

#include 'kernel32.zir';
#include 'user32.zir';
#include 'messages.zir';

#include 'wsock32.zir';
#include 'console.zir';

const DEFAULT_PORT = 1111;

WSOCKET listensocket;
WSOCKET clientsocket;
sockaddr_in addrinfo;

EAX = WSAStartup(WSOCKVER2_2, @ws);
listensocket = socket(PF_INET, SOCK_STREAM, 0);
addrinfo.sin_family = AF_INET;
addrinfo.sin_addr = INADDR_ANY;
addrinfo.sin_port = htons(DEFAULT_PORT);
bind(listensocket, @addrinfo, sizeof sockaddr_in);

listen(listensocket, 20);
while () {
  clientsocket = accept(listensocket, nil, nil);  
  send(clientsocket, 'Hello World!', 12, 0);

//console will never get here. but just in case.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply

Quick reply:


Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 999, May 11, 2018, 10:01 am.

Threads: 224 | Posts: 1841 | Members: 50 | Active Members: 50
Welcome to our newest member, NobodyAtWork
const Copyright = '2011-2019 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd