- tc2-1.00.zip
- TC2-1.00
- HISTORY.TXT
- library
- build
- linux
- windows
- VS2008
- Release
- TC2.dll
- TC2.lib
- TC2.sln
- TC2.vcproj
- TC2.vcproj.ARETEWIN2003.Administrator.user
- doc
- html
- source
- README.TXT
- usage
- gen_client_1
- build
- linux
- windows
- VS2008
- client_1
- client_1.sln
- client_1.suo
- client_1.vcproj
- client_1.vcproj.ARETEWIN2003.Administrator.user
- Debug
- Release
- Client_1.c
- README.TXT
|
/// @source Socket.h
/// @description Public interface for the Socket facility.
// See licensing information in the file README.TXT.
// -----------------------------------------------------------------------------
#ifndef __SOCKET_H__
#define __SOCKET_H__
// -----------------------------------------------------------------------------
// Windows-specific includes
#if PLATFORM(Windows)
// ...
#endif
// Linux-specific includes
#if PLATFORM(Linux)
#include <errno.h>
#include <unistd.h>
#endif
// -----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
// -----------------------------------------------------------------------------
// the redundancy here is for doxygen documentation
// common platform declarations
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// see Socket::socket_connect
extern TC2API bool socket_connect(int, uint, ushort);
/// see Socket::socket_createClientSocket
extern TC2API int socket_createClientSocket(void);
/// see Socket::socket_init
extern TC2API void socket_init(void);
/// see Socket::socket_partialLenReceived
extern TC2API int socket_partialLenReceived(void);
/// see Socket::socket_recvBuffer
extern TC2API int socket_recvBuffer(int, char*, int, uint, bool);
/// see Socket::socket_sendBuffer
extern TC2API int socket_sendBuffer(int, cchar*, int, uint, bool);
/// see Socket::socket_setNonBlocking
extern TC2API void socket_setNonBlocking(int, bool);
// Linux-specific declarations
#if PLATFORM(Linux)
#define socket_shouldRetry(err) (err == EINTR)
#define socket_close close
#define socket_error() errno
#define socket_wouldBlock(err) (err == EWOULDBLOCK)
extern int errno;
#endif
// Windows-specific declarations
#if PLATFORM(Windows)
#define socket_close closesocket
#define socket_error() WSAGetLastError()
#define socklen_t int
#define socket_shouldRetry(err) 0
#define socket_wouldBlock(err) (err == WSAEWOULDBLOCK)
#endif
/// Generic Socket error definition
#define E_SOCKET_ERROR -1
/// Generic timeout Socket error
#define E_SOCKET_TIMEOUT -2
/// Socket closed on reception
#define E_SOCKET_CLOSED 0
// -----------------------------------------------------------------------------
#ifdef __cplusplus
} // #ifdef __cplusplus
#endif
// -----------------------------------------------------------------------------
#endif // __SOCKET_H__
// -----------------------------------------------------------------------------
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a long-time software developer living in Brazil.
I've been developing software for retail and banking automation in C/C++ for many years now. In the old days I even did some COBOL programming, and some assembly for the 8080.
My experience ranges from low level software such as interface code for serial devices for DOS and Windows (bar code scanners, printers, cash dispensers, etc) and goes to writing end user applications for POS terminals and bank ATMs. In between I've done a great deal of TCP/IP programming using the basic Berkeley sockets interface, which is my main interest nowadays.