if you use Qt, why don't you use QtNetwork module instead of using std functions?
if you use Qt, why don't you use QtNetwork module instead of using std functions?
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
i dont have any idea about the QtNetwork modules.
moreover i have already used std fnctions in main.cpp . it worked well
but in separate thread it is using the slot connect.
why ?
read this.
show us compilable example which reproduces the problem.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
This is main.cpp
#include <QtGui/QApplication>
#include "vms.h"
#include "ConnectServer.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <QMessageBox>
#include <QFile>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdint.h>
#include <assert.h>
#include "defines.h"
#include "structs.h"
#include "tsadc.h"
int thresholdValuesem;
void *cThresholdValueAddrs;
key_t semkey;
int shmid;
key_t key;
int gnSampleFactor;
int sockfd;
struct sockaddr_in serv_addr;
struct hostent *host_name;
int SERV_TCP_PORT;
char SERV_HOST_ADDR[20];
char gcPassword[20];
int gnConnectFailed;
tsadc adc;
int main(int argc, char *argv[])
{
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family =AF_INET;
serv_addr.sin_addr.s_addr =inet_addr(SERV_HOST_ADDR);
serv_addr.sin_port =htons(SERV_TCP_PORT);
/*open a TCP socket */
if((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0)
{
vmslog << "VmsERROR:can't open stream socket" << "\n";
vmslog.flush();
}
/*connect to the server*/
if((gnConnectFailed=connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr))) == -1)
{
vmslog << "VmsERROR:can't connect to server" << "\n";
vmslog.flush();
}
QApplication a(argc, argv);
vms w;
w.show();
return a.exec();
}
this is the thread.cpp
#include "ConnectServer.h"
#include <QThread>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ipc.h>
#include <netdb.h>
#include <QMessageBox>
extern int sockfd;
extern struct sockaddr_in serv_addr;
extern int gnConnectFailed;
extern struct hostent *host_name;
extern int SERV_TCP_PORT;
extern char SERV_HOST_ADDR[20];
ConnectServerThread::ConnectServerThread()
{
}
void ConnectServerThread::connectServer()
{
while(gnConnectFailed==-1)
{
/*Reconnect to the server*/
if((gnConnectFailed=connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr))) == -1)
{
//Connection Failed
}
}
}
did you try to write like this?
Qt Code:
if((gnConnectFailed=::connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr))) == -1)To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
i tried in the above manner
successful in compilation. .
but it is still taking the slots connect.(i can say this, as it gives the IntelliSense ).
set a break point in the slot which is called and look at trace log.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
can you also prepare minimal compilable project which we can build by ourself?
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
thnk u for ur support ..
i think it takes hrs to do .. but i wil try
is there any way..?
Horse sense is the thing that keeps horses from betting on people. --W.C. Fields
Ask Smart Questions
::connect will work - ignore Visual studio and Intellisense. Test your app instead.
Show your code, then we can tell why. Probably you aren't using ::connect().
Horse sense is the thing that keeps horses from betting on people. --W.C. Fields
Ask Smart Questions
Bookmarks