MCPcopy Create free account
hub / github.com/F-Stack/f-stack / Connect

Method Connect

adapter/micro_thread/mt_net.cpp:900–951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900bool CSockLink::Connect()
901{
902 this->_last_access = mt_time_ms();
903
904 if (_proto_type == NET_PROTO_UDP)
905 {
906 _state |= LINK_CONNECTED;
907 }
908
909 if (_state & LINK_CONNECTED)
910 {
911 return true;
912 }
913
914 if (_state & LINK_CONNECTING)
915 {
916 return false;
917 }
918
919 struct sockaddr_in addr = {0};
920
921 mt_hook_syscall(connect);
922 int32_t ret = ff_hook_connect(_fd, (struct sockaddr*)this->GetDestAddr(&addr), sizeof(struct sockaddr_in));
923 if (ret < 0)
924 {
925 int32_t err = errno;
926 if (err == EISCONN)
927 {
928 _state |= LINK_CONNECTED;
929 return true;
930 }
931 else
932 {
933 _state |= LINK_CONNECTING;
934 if ((err == EINPROGRESS) || (err == EALREADY) || (err == EINTR))
935 {
936 MTLOG_DEBUG("Open connect not ok, maybe first try, sock %d, errno %d", _fd, err);
937 return false;
938 }
939 else
940 {
941 MTLOG_ERROR("Open connect not ok, sock %d, errno %d", _fd, err);
942 return false;
943 }
944 }
945 }
946 else
947 {
948 _state |= LINK_CONNECTED;
949 return true;
950 }
951}
952
953int32_t CSockLink::SendCacheUdp(void* data, uint32_t len)
954{

Callers 1

WaitConnectMethod · 0.80

Calls 3

GetDestAddrMethod · 0.95
mt_time_msFunction · 0.85
ff_hook_connectFunction · 0.70

Tested by

no test coverage detected