Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Non-Blocking socket example
Re: Socket example? [message #11024 is a reply to message #11012] Wed, 15 August 2007 04:51 Go to previous messageGo to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Could this help as a starting point for your server part:
#include <CtrlLib/CtrlLib.h>
#include <Web/Web.h>

using namespace Upp;

#define LAYOUTFILE <P2PSocket/P2PSocket.lay>
#include <CtrlCore/lay.h>

class  SocketApp : public WithMainLay<TopWindow> {
	Socket sock;
public:
	void SSwitch();
	typedef   SocketApp CLASSNAME;
	SocketApp();
};


void SocketApp::SSwitch()
{
	if (ssw==0) {
		sock.Close();
		PromptOK("4662 socket server CLOSED. You can check it with nmap command");
	}
	else if (ssw==1) {
		ServerSocket(sock, 4662, true, 5, false);
		PromptOK("4662 socket server OPENED. You can check it with nmap command");
	}
	else	
		PromptOK("Warning: check your switch inits!");
}



SocketApp::SocketApp()
{
	CtrlLayout(*this, "P2PSocket Server");
	ssw.SetLabel(0, "STOP 4662");
	ssw.SetLabel(1, "START 4662");
	ssw=0;

	ssw.WhenAction = THISBACK(SSwitch);

	Sizeable().Zoomable();
}


GUI_APP_MAIN
{
	SocketApp().Run();
}



P2PSocket.lay:
LAYOUT(MainLay, 400, 200)
	ITEM(Switch, ssw, HSizePosZ(144, 172).VSizePosZ(68, 96))
END_LAYOUT
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon11.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Again ReadMemoryBarrier() etc
Next Topic: Threading example for U++
Goto Forum:
  


Current Time: Fri May 10 12:57:29 CEST 2024

Total time taken to generate the page: 0.46454 seconds