Вы находитесь на странице: 1из 7

Library Description:

CoDeSys V 3.x
SysSocketAsync.library

Document Version 1.0


libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH Page 1 of 7


SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

CONTENT

1 OVERVIEW 3

2 LIBRARY MODULES 4

CHANGE HISTORY 7
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH Page 2 of 7


SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

1 Overview

Note: It depends on the target system, which system libraries can be used in the application program.

This library supports the asynchronous access on sockets for the purpose of communication
via TCP/IP and UDP. It automatically includes the library SysCom.library for synchronous
communication, whose modules are used as a basis for the corresponding asynchronous
functionality. The modules of SysCom.library make available their parameters to the
SysComAsync.library in appropriate structures. Thus these parameters can be used by the
methods and wrapper-methods of SysComAsync.library.

The target system must support the functionality!

Note:
- The behavior of the functions is target-specific.
- Opening and closing of sockets might take much time, if multiple sockets are opened resp. closed at
the same time.
- Using the asynchronous functions is recommended.
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH Page 3 of 7


SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

2 Library Modules

Due to the fact that the async-functionality for file accesses is basing on the modules of
SysSocket.library, using wrapper-methods and shared structures (DUTs), the async-modules
always need the following input parameters:
Input variable Data type Description

p<Function of the POINTER TO Pointer on the structure containing the parameters


SysSocket.library> t<Function of of the corresponding SysCom.library function.
SysSocket.library>
e.g. variable pSysSockCreate and structure
tSysSocketCreate

pudState POINTER TO Pointer on current status:


UDINT
ASYNCSTATE_INVALID
: UDINT := 16#FFFFFFFF;
ASYNCSTATE_PENDING
: UDINT := 0;
ASYNCSTATE_ACTIVE
: UDINT := 1;
ASYNCSTATE_READY
: UDINT := 2;
ASYNCSTATE_ERROR
: UDINT := 3;
ASYNCSTATE_TIMEOUT
: UDINT := 4;

pResult POINTER TO Pointer on error code; see document Runtime


UDINT Error Codes.

The methods of type SysSockFB:

SysSockAcceptAsync
SysSockBindAsync
SysSockCloseAsync
SysSockCloseUdpAsync
SysSockConnectAsync
SysSockCreateAsync
SysSockCreateUdpAsync
SysSockGetHostByNameAsync
SysSockGetHostNameAsync
SysSockGetOptionAsync
SysSockGetOSHandleAsync
SysSockGetRecvSizeUdpAsync
libdoc_e.dot / V1.0

SysSockGetSubnetMaskAsync
SysSockHtonlAsync
SysSockHtonsAsync
SysSockInetAddrAsync
3S - Smart Software Solutions GmbH Page 4 of 7
SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

SysSockInetNtoaAsync
SysSockloctlAsync
SysSockListenAsync
SysSockNtohIAsync
SysSockNtohsAsync
SysSockPingAsync
SysSockRecvAsync
SysSockRecvFromAsync
SysSockRecvFromUdpAsync
SysSockSelectAsync
SysSockSendAsync
SysSockSendToAsync
SysSockSendToUdpAsync
SysSockSetIPAddressAsync
SysSockSetOptionAsync
SysSockSetSubnetMaskAsync
SysSockShutdownAsync

For each of the methods a corresponding wrapper-method is called: <method name>wrapper

The structures (DUTs, Data Unit Types) are named according to the following syntax:
t<function of SysSocket.library>. Example: tSysSockCreate.

The return value of each SysSocket.library function is provided in a correspondingly named


component of the structure element associated to that function:
Type of return value of SysSocket.library- Name of structure component
Funktion

BYTE t<Function of SysSocket.library>.pbyOut

UDINT t<Function of SysSocket.library>.pulOut

WORD t<Function of SysSocket.library>.pusOut

STRING t<Function of SysSocket.library>.pszOut

The status at starting the asynchronous job always is ASYNCSTATE_INVALID.

Example:
DECLARATION:
udStateOpen: UDINT := ASYNCSTATE_INVALID;
TestFB : SysSockAsyncFB;
libdoc_e.dot / V1.0

SSC : tSysSockCreate;
TestType, TestProtocol: DINT;
Result, ResultAsync, OUT, hJob: UDINT;

3S - Smart Software Solutions GmbH Page 5 of 7


SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

IMPLEMENTATION:
SSC.iAddressFamily := adr(Result);
SSC.diType := TestType;
SSC.diProtocol:= TestProtocol;
SSC.pResult:= adr(Result);
SSC.pulOut:= adr(OUT);
hJob := TestFB.SysSockCreateAsync(adr(SSC), adr(udStateOpen),
adr(ResultAsync));

When calling the method SysSockCreate, the asynchronous job gets started. The job will be
finished as soon as the status has got one of the following three values:

ASYNCSTATE_READY: Job successfully finished

ASYNCSTATE_ERROR: Job terminated with error

ASYNCSTATE_TIMEOUT: Job timeout reached before job could be finished


successfully

In the parameter ResultAsync the error code of the method SysSockCreateAsync is returned.
This error code indicates only, if the asynchronous job could be created. The variable hJob is
assigned to the handle of this asynchronous job. By use of this handle and the access
functions within the library CmpAsyncMgr.library, further information on this job can be
retrieved.

The job being processed with status ASYNCSTATE_READY or ASYNCSTATE_ERROR you


find the results of the asynchronous operation in the structure SSC.

For a description of the particular parameters please see the chapters on the corresponding
functions in the documentation on SysFile.library.
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH Page 6 of 7


SysSocketAsync_V3x_E.doc
Library SysSocketAsync.library

Change History
Version Description Date

0.1 Issued acc. to German Version 0.1 09.08.2007


0.2 Completion according to German Version 1.0 19.02.2008
1.0 Release after formal review 20.02.2008
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH Page 7 of 7


SysSocketAsync_V3x_E.doc

Вам также может понравиться