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

Method mt_multi_newsock

adapter/micro_thread/mt_concurrent.cpp:93–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93int NS_MICRO_THREAD::mt_multi_newsock(IMtActList& req_list)
94{
95 int sock = -1, has_ok = 0;
96 IMtAction* action = NULL;
97 IMtConnection* net_handler = NULL;
98
99 for (IMtActList::iterator it = req_list.begin(); it != req_list.end(); ++it)
100 {
101 action = *it;
102 if (NULL == action)
103 {
104 action->SetErrno(ERR_PARAM_ERROR);
105 MTLOG_ERROR("Invalid param, conn %p null!!", action);
106 return -1;
107 }
108
109 if (action->GetErrno() != ERR_NONE) {
110 continue;
111 }
112
113 net_handler = action->GetIConnection();
114 if (NULL == net_handler)
115 {
116 action->SetErrno(ERR_FRAME_ERROR);
117 MTLOG_ERROR("Invalid param, conn %p null!!", net_handler);
118 return -2;
119 }
120
121 sock = net_handler->CreateSocket();
122 if (sock < 0)
123 {
124 action->SetErrno(ERR_SOCKET_FAIL);
125 MTLOG_ERROR("Get sock data failed, ret %d, errno %d!!", sock, errno);
126 return -3;
127 }
128 has_ok = 1;
129
130 if (action->GetProtoType() == MT_UDP)
131 {
132 action->SetMsgFlag(MULTI_FLAG_OPEN);
133 }
134 else
135 {
136 action->SetMsgFlag(MULTI_FLAG_INIT);
137 }
138 }
139
140 if (has_ok)
141 {
142 return 0;
143 }
144 else
145 {
146 return -4;
147 }
148}
149
150int NS_MICRO_THREAD::mt_multi_open(IMtActList& req_list, int timeout)

Callers

nothing calls this directly

Calls 6

SetErrnoMethod · 0.80
GetErrnoMethod · 0.80
GetIConnectionMethod · 0.80
SetMsgFlagMethod · 0.80
CreateSocketMethod · 0.45
GetProtoTypeMethod · 0.45

Tested by

no test coverage detected