D.I.T. ( Do It Tizen! )  1.0.0
Samsung Software Membership
 All Data Structures Files Functions Macros Pages
Functions
Socket.c File Reference

Socket API가 정의되어있다. More...

#include "Commnucation/Socket.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <dlog.h>
#include <curl.h>
#include <system_info.h>
Include dependency graph for Socket.c:

Functions

Socket NewSocket (void)
 새로운 Socket 객체를 생성한다. More...
 
void DestorySocket (Socket this_gen)
 생성한 Socket 객체를 소멸 시킨다. More...
 
bool isSocketAccessible (Socket this_gen)
 TCP/UDP 연결 지원 여부를 반환한다. More...
 
bool onSocketConnect (Socket this_gen, String url, int port)
 TCP/UDP 로 연결을 시도하며 이의 성공 여부를 반환한다. More...
 
bool onSocketDisconnect (Socket this_gen)
 TCP/UDP 로 연결 해제하며 이의 성공 여부를 반환한다. More...
 
bool SocketMessageSend (Socket this_gen, String msg)
 TCP/UDP 연결로 데이터를 송신하며 이의 성공 여부를 반환한다. More...
 
bool SocketMessageRecv (Socket this_gen, String *msg)
 TCP/UDP 연결로 데이터를 수신하며 이의 성공 여부를 반환한다. More...
 
const char * SocketErrorCheck (CURLcode errorCode)
 Socket API에서 발생하는 Error Code들을 확인 해준다. More...
 

Detailed Description

Socket API가 정의되어있다.

Note
Socket API가 정의되어있다.
See Also
Socket.h

Function Documentation

void DestorySocket ( Socket  this_gen)

생성한 Socket 객체를 소멸 시킨다.

Parameters
[in]this_gen소멸시킬 Socket 객체
[out]null
Return values
void
Note
생성한 Socket 객체를 소멸 시킨다.
Socket 객체를 사용한 후 반드시 호출해야 한다.
See Also
NewSocket
Precondition
privilege
bool isSocketAccessible ( Socket  this_gen)

TCP/UDP 연결 지원 여부를 반환한다.

Parameters
[in]this_gen지원 여부를 반환 할 Socket 객체
[out]null
Return values
bool
함수의 성공 여부를 반환한다.
실패시 false를 반환하며 상세한 원인을 Log로 출력한다.
Note
TCP/UDP 연결 지원 여부를 반환한다.
지원 가능 시 true, 불가능 시 false를 반환한다.
See Also
NewSocket
DestorySocket
onSocketConnect
onSocketDisconnect
SocketMessageSend
SocketMessageRecv
Precondition
privilege

Here is the caller graph for this function:

Socket NewSocket ( void  )

새로운 Socket 객체를 생성한다.

Parameters
[in]void
[out]null
Return values
Socket
Note
새로운 Socket 객체를 생성한다.
Socket 객체를 사용하기 전에 반드시 호출해야 한다.
See Also
DestorySocket
isSocketAccessible
onSocketConnect
onSocketDisconnect
SocketMessageSend
SocketMessageRecv
Precondition
privilege
Warning
사용이 끝났을 때 DestorySocket() 함수를 꼭 사용해야 한다.
Socket NewSocket (void)
{
SocketExtends * this = (SocketExtends *)malloc (sizeof (SocketExtends));
this->socket.isAccessible = isSocketAccessible;
this->socket.onConnect = onSocketConnect;
this->socket.onDisconnect = onSocketDisconnect;
this->socket.Send = SocketMessageSend;
this->socket.Recv = SocketMessageRecv;
this->curl = NULL;
this->access = false;
this->conect = false;
return &this->socket;
}

Here is the call graph for this function:

bool onSocketConnect ( Socket  this_gen,
String  url,
int  port 
)

TCP/UDP 로 연결을 시도하며 이의 성공 여부를 반환한다.

Parameters
[in]this_gen연결 성공 여부를 확인할 Socket 객체
[in]url연결을 시도할 URL
[in]port연결을 시도할 포트 번호
[out]null
Return values
bool
함수의 성공 여부를 반환한다.
실패시 false를 반환하며 상세한 원인을 Log로 출력한다.
Note
TCP/UDP 로 연결을 시도하며 이의 성공 여부를 반환한다.
연결에 성공하면 true, 실패하면 false를 반환한다.
See Also
NewSocket
DestorySocket
isSocketAccessible
onSocketDisconnect
SocketMessageSend
SocketMessageRecv
Precondition
privilege

Here is the call graph for this function:

Here is the caller graph for this function:

bool onSocketDisconnect ( Socket  this_gen)

TCP/UDP 로 연결 해제하며 이의 성공 여부를 반환한다.

Parameters
[in]this_gen연결 해제 여부를 확인할 Socket 객체
[out]null
Return values
bool
함수의 성공 여부를 반환한다.
실패시 false를 반환하며 상세한 원인을 Log로 출력한다.
Note
TCP/UDP 로 연결을 제하며 이의 성공 여부를 반환한다.
연결 해제에 성공하면 true, 실패하면 false를 반환한다.
See Also
NewSocket
DestorySocket
isSocketAccessible
onSocketConnect
SocketMessageSend
SocketMessageRecv
Precondition
privilege

Here is the caller graph for this function:

const char* SocketErrorCheck ( CURLcode  errorCode)

Socket API에서 발생하는 Error Code들을 확인 해준다.

Parameters
[in]errCode확인 하고자 하는 Error Code
[out]null
Return values
CURLE_OK
CURLE_UNSUPPORTED_PROTOCOL
CURLE_FAILED_INIT
CURLE_URL_MALFORMAT
CURLE_NOT_BUILT_IN
CURLE_COULDNT_RESOLVE_PROXY
CURLE_COULDNT_RESOLVE_HOST
CURLE_COULDNT_CONNECT
CURLE_FTP_WEIRD_SERVER_REPLY
CURLE_REMOTE_ACCESS_DENIED: A service was denied by the server due to lack of access - when login fails this is not returned.
CURLE_FTP_ACCEPT_FAILED
CURLE_FTP_WEIRD_PASS_REPLY
CURLE_FTP_ACCEPT_TIMEOUT: Timeout occurred accepting server
CURLE_FTP_WEIRD_PASV_REPLY
CURLE_FTP_WEIRD_227_FORMAT
CURLE_FTP_CANT_GET_HOST
CURLE_FTP_COULDNT_SET_TYPE
CURLE_PARTIAL_FILE
CURLE_FTP_COULDNT_RETR_FILE
CURLE_QUOTE_ERROR: Quote command failure
CURLE_HTTP_RETURNED_ERROR
CURLE_WRITE_ERROR
CURLE_UPLOAD_FAILED: Failed upload "command"
CURLE_READ_ERROR: Couldn't open/read from file
CURLE_OUT_OF_MEMORY
CURLE_OPERATION_TIMEDOUT: The timeout time was reached
CURLE_FTP_PORT_FAILED: FTP PORT operation failed
CURLE_FTP_COULDNT_USE_REST: The REST command failed
CURLE_RANGE_ERRORRANGE : Command" didn't work
CURLE_HTTP_POST_ERROR
CURLE_SSL_CONNECT_ERROR: Wrong when connecting with SSL
CURLE_BAD_DOWNLOAD_RESUME: Couldn't resume download
CURLE_FILE_COULDNT_READ_FILE
CURLE_LDAP_CANNOT_BIND
CURLE_LDAP_SEARCH_FAILED
CURLE_FUNCTION_NOT_FOUND
CURLE_ABORTED_BY_CALLBACK
CURLE_BAD_FUNCTION_ARGUMENT
CURLE_INTERFACE_FAILED
CURLE_TOO_MANY_REDIRECTS: Catch endless re-direct loops
CURLE_UNKNOWN_OPTION: User specified an unknown option
CURLE_TELNET_OPTION_SYNTAX: Malformed telnet option
CURLE_PEER_FAILED_VERIFICATION: Peer's certificate or finger print wasn't verified fine
CURLE_GOT_NOTHING: When this is a specific error
CURLE_SSL_ENGINE_NOTFOUND: SSL crypto engine not found
CURLE_SSL_ENGINE_SETFAILED: Can not set SSL crypto engine as default
CURLE_SEND_ERROR: Failed sending network data
CURLE_RECV_ERROR: Failure in receiving network data
CURLE_SSL_CERTPROBLEM: Problem with the local certificate
CURLE_SSL_CIPHER: Couldn't use specified cipher
CURLE_SSL_CACERT: Problem with the CA cert
CURLE_BAD_CONTENT_ENCODING: Unrecognized/bad encoding
CURLE_LDAP_INVALID_URL: Invalid LDAP URL
CURLE_FILESIZE_EXCEEDED: Maximum file size exceeded
CURLE_USE_SSL_FAILED: Requested FTP SSL level failed
CURLE_SEND_FAIL_REWIND: Sending the data requires a rewind that failed
CURLE_SSL_ENGINE_INITFAILED: Failed to initialize ENGINE
CURLE_LOGIN_DENIED: User, password or similar was not accepted and we failed to login
CURLE_TFTP_NOTFOUND: File not found on server
CURLE_TFTP_PERM: Permission problem on server
CURLE_REMOTE_DISK_FULL: Out of disk space on server
CURLE_TFTP_ILLEGAL: Illegal TFTP operation
CURLE_TFTP_UNKNOWNID: Unknown transfer ID
CURLE_REMOTE_FILE_EXISTS: File already exists
CURLE_TFTP_NOSUCHUSER: No such user
CURLE_CONV_FAILED: Conversion failed
CURLE_CONV_REQD: Caller must register conversion callbacks using curl_easy_setopt options.
CURLE_SSL_CACERT_BADFILE: Could not load CACERT file, missing or wrong format
CURLE_REMOTE_FILE_NOT_FOUND: Remote file not found
CURLE_SSH: Error from the SSH layer, somewhat generic so the error message will be of interest when this has happened
CURLE_SSL_SHUTDOWN_FAILED: Failed to shut down the SSL connection
CURLE_AGAIN: Socket is not ready for send/recv wait till it's ready and try again
CURLE_SSL_CRL_BADFILE: Could not load CRL file, missing or wrong format
CURLE_SSL_ISSUER_ERROR: Issuer check failed
CURLE_FTP_PRET_FAILED: A PRET command failed
CURLE_RTSP_CSEQ_ERROR: Mismatch of RTSP CSeq numbers
CURLE_RTSP_SESSION_ERROR: Mismatch of RTSP Session Ids
CURLE_FTP_BAD_FILE_LIST: Unable to parse FTP file list
CURLE_CHUNK_FAILED: Chunk callback reported error
CURL_LAST
Note
Socket API에서 발생하는 Error Code들을 확인 해준다.
Error의 내용은 Log를 통해 출력 된다.
See Also
Libcurl Error Document

Here is the caller graph for this function:

bool SocketMessageRecv ( Socket  this_gen,
String *  msg 
)

TCP/UDP 연결로 데이터를 수신하며 이의 성공 여부를 반환한다.

Parameters
[in]this_gen데이터를 수신할 Socket 객체
[in]msg수신할 데이터를 저장할 주소
[out]msg수신한 데이터
Return values
bool
함수의 성공 여부를 반환한다.
실패시 false를 반환하며 상세한 원인을 Log로 출력한다.
Note
TCP/UDP 연결로 데이터를 수신하며 이의 성공 여부를 반환한다.
수신에 성공하면 true, 실패하면 false를 반환한다.
See Also
NewSocket
DestorySocket
isSocketAccessible
onSocketConnect
onSocketDisconnect
SocketMessageSend
Precondition
privilege

Here is the call graph for this function:

Here is the caller graph for this function:

bool SocketMessageSend ( Socket  this_gen,
String  msg 
)

TCP/UDP 연결로 데이터를 송신하며 이의 성공 여부를 반환한다.

Parameters
[in]this_gen데이터를 송신할 Socket 객체
[in]msg송신할 데이터
[out]null
Return values
bool
함수의 성공 여부를 반환한다.
실패시 false를 반환하며 상세한 원인을 Log로 출력한다.
Note
TCP/UDP 연결로 데이터를 송신하며 이의 성공 여부를 반환한다.
송신에 성공하면 true, 실패하면 false를 반환한다.
See Also
NewSocket
DestorySocket
isSocketAccessible
onSocketConnect
onSocketDisconnect
SocketMessageRecv
Precondition
privilege

Here is the call graph for this function:

Here is the caller graph for this function: