?? function_tcp.h
字號(hào):
#ifndef _FUNCTION_TCP_H
#define _FUNCTION_TCP_H_
#include <stdio.h>
#include <csl.h>
#include <std.h>
#include <csl_timer.h>
#include <csl_irq.h>
#include <csl_mdio.h>
#include "MyDefine.h"
typedef struct sockaddr SA;
typedef struct sockaddr *PSA;
// File Descriptor Functions
int fdOpenSession( Handle hTask );
void fdCloseSession( Handle hTask );
int fdSelect( int width, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout );
void fdSelectAbort( Handle hTask );
int fdClose( int fd );
Handle fdGetFileHandle( int fd );
int fdError();
int fdTransfer( Handle hSrcTask, int srcfd, Handle hDstTask, int *pdstfd );
int fdShare( Handle hSrcTask, int srcfd,
Handle hDstTask, int dstfdpref, int *pdstfd );
int fdShareAll( Handle hSrcTask, Handle hDstTask );
// File Handle Functions
void FileHandleClose( Handle h );
int FileHandleGetFd( Handle h );
// Socket Oriented Functions
int accept( int s, PSA pName, int *plen );
int bind( int s, PSA pName, int len );
int connect( int s, PSA pName, int len );
int getpeername( int s, PSA pName, int *plen );
int getsockname( int s, PSA pName, int *plen );
int getsockopt( int s, int level, int op, void *pbuf, int *pbufsize );
int listen( int s, int maxcon );
int recv( int s, void *pbuf, int size, int flags );
int recvfrom( int s, void *pbuf, int size, int flags, PSA pName, int *plen );
int recvnc( int s, void **ppbuf, int flags, Handle *pHandle );
int recvncfrom( int s, void **ppbuf, int flags,
PSA pName, int *plen, Handle *pHandle );
void recvncfree( Handle Handle );
int send( int s, void *pbuf, int size, int flags );
int sendto( int s, void *pbuf, int size, int flags, PSA pName, int len );
int setsockopt( int s, int level, int op, void *pbuf, int bufsize );
int shutdown( int s, int how );
int socket( int domain, int type, int protocol );
int socketpair( int domain, int type, int protocol, int s[2] );
// Pipe Oriented Functions
int pipe( int *pfd1, int *pfd2 );
/*
將用點(diǎn)分割的IP地址轉(zhuǎn)換位一個(gè)in_addr結(jié)構(gòu)的地址,這個(gè)結(jié)構(gòu)的定義見(jiàn)筆記(一),
實(shí)際上就是一個(gè)unsigned long值。計(jì)算機(jī)內(nèi)部處理IP地址可是不認(rèn)識(shí)
如192.1.8.84之類的數(shù)據(jù)。
unsigned long inet_addr( const char FAR * cp );
舉例:inet_addr("192.1.8.84")=1409810880
inet_addr("127.0.0.1")= 16777343
7、將網(wǎng)絡(luò)地址轉(zhuǎn)換位用點(diǎn)分割的IP地址,是上面函數(shù)的逆函數(shù)。
char FAR * inet_ntoa( struct in_addr in );
舉例:char * ipaddr=NULL;
char addr[20];
in_addr inaddr;
inaddr. s_addr=16777343;
ipaddr= inet_ntoa(inaddr);
strcpy(addr,ipaddr);
這樣addr的值就變?yōu)?27.0.0.1。
注意意不要修改返回值或者進(jìn)行釋放動(dòng)作。如果函數(shù)失敗就會(huì)返回NULL值。*/
#endif /*---Function_TCP.h---*/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -