Monday, October 10, 2011

Winsock Programming sample project cyber management system.

 Cyber Management System is a program which interconnects different computers which allows users to communicate over the computer network and provide security from unauthorized users by login system in client server.
The project is based on the client server architecture and its communication protocols. The project basically is divided into two sections:- Cyber server and Client server. Not only a single, multiple client can connect to cyber server at any time. Cyber server has the full control over Client server. Client server is password protected user has to login to access internet and other services. New user can signup for username and password. Price rate and services is fixed by cyber server. Client can request any service sending message to cyber server.

Major component

socket API

int socket( int domain , inttype , intprotoco ) ;

Returnsa file descriptor(called a socket ID), if successful, -1 otherwise.Note that the socket returns a socket descriptor which is the same as a file descriptor.
The domain is AF INET.
The type argument can be:
SOCK STREAM: Establishes a virtual circuit for stream
SOCK DGRAM: Establishes a datagram for communication
SOCK SEQPACKET: Establishes a reliable, connection based,two way communicationwith maximum message size. (This isnot available on most machines.)
PROTOCOL is usually zero, so that type defines the connectionwithin domain
int bind (intsid , structsock addr _addrPtr ,intlen);
sid: is the socket id
addrPtr: is a pointer to the address family dependentaddress structure
len: is the size of *addrPtr
This associates a socket id with an address to which other processes
can connect. In internet protocol the address is [ipNumber,portNumber]

 intlisten( int sid ,int size);
Where size it the number of pending connection requests allowed (typically limited by Unix kernels to 5).Returns the 0 on success, or -1 if failure. The server process calls listen to tell the kernel to initialize a wait queue of connections for
this socket.

intaccept (intsid , structsock addr _addrPtr , int _lenPtr)
Returns the socketId and address of client connecting to socket. if lenPtr or addrPtr equal zero, no address structure is returned. lenPtr is the maximum size of address structure that can be called, returns the actual value. Waits for an incoming request, and when received creates a socket for it.

This is the first of the client calls to connect to a server port
int connect ( int sid , struct sock addr _addrPt r ,int len)
Specifies the destination to form a connection with (addrPtr), and returns a 0 if successful, -1 otherwise.

 int send ( int sid , const char _bufferPtr ,int len , int  flag)

Send a message. Returns the number of bytes sent or -1 if failure (Must be a bound socket).
flag is either
0: default
MSG OOB: Out-of-band high priority communication

int recv (intsid , char _bufferPtr ,int len ,int flags)
Receive up to len bytes in bufferPtr. Returns the number ofbytes received or -1 on failure.
flags can be either
0: default
MSG OOB: out-of-bound message
MSG PEEK: look at message without removing

closesocket– Close the socket
Close signals the end of communication between a server-client pair. This effectively closes the socket.
Int close(int sock)
sock = the socket to close

IP Addressing
Each IP address has specific components and follows a basic format.These can be sub divided and used to create addresses for sub networks. Each host on a TCP/IP network is assigned a unique 32-bit logical address that is divided into two main parts: the network number and the host number. In our program server cerates the sockets and bind the IP address as the address of the socket on the server then only connection is establish with a specific client.

Port Numbers
A port number is a way to identify a specific process to which an Internet or other network message is to be forwarded when it arrives at a server. For the Transmission Control Protocol and the User Datagram Protocol, a port number is a 16-bit integer that is put in the header appended to a message unit. In our program a port numberis part of the addressing information used to identify the senders and receivers of messages.

A thread is basically a path of execution through a program. It is also the smallest unit of execution that Win32 schedules. A thread consists of a stack, the state of the CPU registers, and an entry in the execution list of the system scheduler. Each thread shares all the process's resources.
A process consists of one or more threads and the code, data, and other resources of a program in memory. Typical program resources are open files, semaphores, and dynamically allocated memory. A program executes when the system scheduler gives one of its threads execution control. The scheduler determines which threads should run and when they should run. Threads of lower priority might have to wait while higher priority threads complete their tasks. On multiprocessor machines, the scheduler can move individual threads to different processors to balance the CPU load.

You can download full source code and exe file from this link Cybermanagement_sourcecode for further help and solution you can mail me.

1 comment:

  1. Can we have the source code for this cyber management.