Все. Я понял что тупой.
Три дня играюсь с сокетом но всегда получаю сообщение
received message (connection 16777343): Content-Type: command/reply
Reply-Text: -ERR command parse error.
FreeSWITCH version: 1.5.15b 32bit
Пробовал одним махом отправить, пробовал \n повыносить в отдельную запись, экспериментировал с \r, и его сочетанием с \n.
Пробавал делать задерку и даже от отчаяния всякую хрень подставлял. event-lock: true и в переди вставлял и сзади и убирал нафиг, ну не парстится и все тут.
Вывод Дебага
Цитата:
oleg-desktop:/usr/share/call-taxi/call-taxi-ATS#
[debug] port 8084
new connection established ID=16777343
[server say]: connect
received message (connection 16777343):
Event-Name: CHANNEL_DATA
Core-UUID: 2b6d031f-bef8-4848-8124-fb5d0c3b2782
|
| тут пропускаю чтоб не объемно было
|
|
variable_current_application: socket
variable_socket_host: 127.0.0.1
Content-Type: command/reply
Reply-Text: %2BOK%0A
Socket-Mode: async
Control: full
[server say]: sendmsg
call-command: execute
execute-app-name: answer
event-lock: true
received message (connection 16777343): Content-Type: command/reply
Reply-Text: -ERR command parse error.
Content-Type: text/disconnect-notice
Controlled-Session-UUID: f8858027-6a92-4cb6-8817-99c46236c032
Content-Disposition: disconnect
Content-Length: 67
Disconnected, goodbye.
See you at ClueCon!
http://www.cluecon.com/отправляю так
Код:
char* _msg_ ="sendmsg\n" ;
if(!nws_send_message(_connection_, _msg_, strlen(_msg_)+1)) {
printf("sending repeat failed\n");
}
char* _com_ ="call-command: execute\n" ;
if(!nws_send_message(_connection_, _com_, strlen(_com_)+1)) {
printf("sending repeat failed\n");
}
char* _ex_ ="execute-app-name: answer\n\n" ;
if(!nws_send_message(_connection_, _ex_, strlen(_ex_)+1)) {
printf("sending repeat failed\n");
}
char* _eventlock_ ="event-lock: true" ;
if(!nws_send_message(_connection_, _eventlock_, strlen(_eventlock_)+1)) {
printf("sending repeat failed\n");
}
------------------------ вставляю функции по цепочке может в какой из них засада -------------------------------------
Код:
int nws_send_message(struct nws_tag_connection_card* _connection_, void* _message_, int _message_size_) {
//
int _result_ = TRUE;
//
// lock data
pthread_mutex_lock(&_cmutex_);
//
// test socket is alive
if(socket_is_alive(_connection_->_socket_)) {
//
// two attempts
_result_ = FALSE;
//
int i=0;
//
int _write_result_;
//
for(;i<2;i++) {
//
// connection proto
if(_nwconf_protocol_ == CP_TCP_IP) {
//
#if (defined DEBUG)
printf("sending repeat write_TCP\n");
#endif
// send data
_write_result_ = write_TCP(_connection_->_socket_, _message_, _message_size_);
}
else if(_nwconf_protocol_ == CP_UDP) {
//
// send data
_write_result_ = write_UDP(_connection_->_socket_, _message_, _message_size_, &(_connection_->_peer_addr_));
}
else if(_nwconf_protocol_ == CP_SOCKET) {
//
// send data
_write_result_ = write_UDP(_connection_->_socket_, _message_, _message_size_, &(_connection_->_peer_addr_));
}
//
// check
if(_write_result_ == SOCKET_ERROR) {
//
// simple reason
if((errno == EAGAIN) || (errno == EWOULDBLOCK))
continue;
//
// unmanner reason
break;
}
else {
//
// data was sent
#if (defined DEBUG)
printf("sending write_TCP OK\n");
#endif
_result_ = TRUE;
//
break;
}
}
}
else _result_ = FALSE;
//
// unlock data
pthread_mutex_unlock(&_cmutex_);
//
return _result_;
}
int write_TCP (
sock_t handle, /* Socket handle */
const void *buffer, /* Buffer containing data */
size_t length /* Amount of data to write */
)
{
#if (defined (DOES_SOCKETS))
# if (defined (__UTYPE_BEOS))
return (send ((SOCKET) handle, buffer, length, 0));
# elif (defined (__UNIX__) || defined (__VMS__) || defined (__OS2__))
return (write ((SOCKET) handle, buffer, length));
# elif (defined (__WINDOWS__))
int
rc; /* Return code from call */
ASSERT (buffer);
rc = send ((SOCKET) handle, buffer, length, 0);
return (win_error (rc));
# else
# error "No code for function body."
# endif
#else
return ((int) SOCKET_ERROR); /* Sockets not supported */
#endif
}