HN-Community
socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - Printable Version

+- HN-Community (https://hacker-newbie.org)
+-- Forum: Miscellaneous (https://hacker-newbie.org/forum-86.html)
+--- Forum: Coding/Programing (https://hacker-newbie.org/forum-19.html)
+---- Forum: Aplication Programing (https://hacker-newbie.org/forum-39.html)
+---- Thread: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D (/thread-6887.html)



socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - syn_attack - 02-01-2011

/*c0ded by Paulus 'deathfinger' Gandung
a.k.a syn-attack
a.k.a mercenary in network
quote : "brainmind is not dependable by your title and your achievement, but by your capability"
*/

#ifndef SOCKET_H
#define SOCKET_H
#include <WinSock2.h>
#include <string>

enum TypeSocket {BlockingSocket, NonBLockingSocket};

class Socket {
public :

virtual ~Socket();
Socket(const Socket&);
Socket& operator = (Socket&);

std::string ReceiveLine();
std::string ReceiveBytes();

void Close();

// the parameter of SendLine is not a const reference
// because SendLine modifies the std::string passed
void SendLine(std::string);

// the parameter of SendBytes is a const reference
// because SendBytes does not modify the std::string passed
// (in contrast to SendLine)
void SendBytes(const std::string&);
protected :
friend class SocketServer;
friend class SocketSelect;

Socket(SOCKET s);
Socket();

SOCKET s_;

int* refCounter_;

private :
static void Start();
static void End();
static int nofSockets_;
};

class SocketClient : public Socket {
public :
SocketClient(const std::string& host, int port);
};

class SocketServer : public Socket {
public :
SocketServer(int port, int connections, TypeSocket type = BlockingSocket);

Socket* Accept();
};

class SocketSelect {
public :
SocketSelect(Socket const * const s1, Socket const * const s2 = NULL, TypeSocket type = BlockingSocket);

bool Readable(Socket const * const s);

private :
fd_set fds_;
};

#endif


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - Sidom - 02-01-2011

sedap./.ijin explore sourcenya
cendol untuk mu


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - syn_attack - 02-01-2011

simpan dengan nama socket.h ya kak sidom...... :D
kalau ada yang salah mohon untuk dimaafkan ya kak...... :D


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - MYGO - 02-01-2011

Izin Mempelajarinya yah...


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - syn_attack - 02-01-2011

<html>
<head>
<title>gandungred</title>
</head>
<body text = "red" align = "center">
"brainmind is not dependable by your title and achievement, but by your capability"
</body>
</html>
oke kak MYGO.....
boleh kak,, monggo,, memang code ini dibuat opensource......


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - bi0zcode - 02-06-2011

wow , ini lebih oop keknya *soktau


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - syn_attack - 02-07-2011

@kak bi0zc0de~# benr banget kak..... ini mengarah ke OOP (pemrograman berbasis obyek)........ :D

c0py paste aja kak bi0zcode,, ini opensource koq.....

hahahahahhaha :D


RE: socket.h (made by me) a.k.a file header untuk C++ socket programming....... :D - syn_attack - 02-07-2011

@ all : file header ini lumayan,, lumayan untuk menambah library di visual C++ 2010....

heheh :D