Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
frmclient.cpp
Package: Webserver.rar [view]
Upload User: yayahi0755
Upload Date: 2022-05-14
Package Size: 876k
Code Size: 2k
Category:
Browser Client
Development Platform:
Unix_Linux
- #include "frmclient.h"
- /*
- * Constructs a frmclient which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
- *
- * The dialog will by default be modeless, unless you set 'modal' to
- * TRUE to construct a modal dialog.
- */
- static const Q_UINT16 ipcPort = 8000;
- frmclient::frmclient( QWidget* parent, const char* name, bool modal, WFlags fl )
- : clientform( parent, name, modal, fl )
- {
- socket =new QSocket (this);
- connectFlag=FALSE;
- connect( socket, SIGNAL(connected()), this ,SLOT(SocketConnected()));
- connect( socket, SIGNAL(connectionClosed()), this, SLOT(ServerConnectionClosed()) );
- connect( socket, SIGNAL(error(int)), this ,SLOT(SocketError(int)) );
- connect( btnSendPicture, SIGNAL(clicked()), SLOT(sendImage()) );
- connect( btnSendText, SIGNAL(clicked()), SLOT(sendText()) );
- connect( btnSendFile, SIGNAL(clicked()), SLOT(sendFile()) );
- connect( btnConnect, SIGNAL( clicked()), SLOT( connectNet()));
- connect( btnExit, SIGNAL( clicked()), SLOT(exitSystem()));
- socket->connectToHost( "196.168.0.100", ipcPort );
- }
- /*
- * Destroys the object and frees any allocated resources
- */
- frmclient::~frmclient()
- {
- // no need to delete child widgets, Qt does it all for us
- }
- void frmclient::ServerConnectionClosed()
- {
- connectFlag=FALSE;
- txtContent->append (tr("disconnect net"));
- }
- void frmclient::SocketConnected()
- {
- connectFlag=TRUE;
- txtContent->append (tr("connect net"));
- }
- void frmclient::SocketError(int error)
- {
- txtContent->append( tr("Error number %1 occurredn").arg(error) );
- }
- void frmclient::connectNet()
- {
- socket->connectToHost( "192.168.0.100", ipcPort );
- }
- void frmclient::sendImage()
- {
- QString imageName=txtContent->text();
- QImage image( imageName );
- if ( !image.isNull() ) {
- sendPacket( image );
- }
- }
- void frmclient::sendText()
- {
- if(connectFlag)
- sendPacket( txtContent->text() );
- else
- txtContent->append (tr("Net is not connected"));
- }
- void frmclient::sendFile()
- {
- txtContent->setText("");
- }
- void frmclient::sendPacket( const QVariant &v )
- {
- QByteArray ba;
- QDataStream varDs( ba, IO_WriteOnly );
- varDs << v;
- QDataStream ds( socket );
- ds << (Q_UINT32) ba.size();
- socket->writeBlock( ba.data(), ba.size() );
- }
- void frmclient::exitSystem()
- {
- close();
- }