w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Run a python socket server and if closed remotely start it listening again
The way you usually program a threaded socket server is: call accept() in a loop spawn a new thread to handle the new connection A very minimal example would be somethig like this: import socket import threading import time server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(('0.0.0.0', 9999)) server.listen(1) def handle(conn): conn.send(b'hello') time.sleep(1) # do some "heavy" work conn.close() while True: print('listening...') conn, addr = server.accept() print('handling connection from %s' % (addr,)) threading.Thread(target=handle, args=(conn,)).start() You're spawning new threads in which you create your listening socket, then accept and handle your connection. And while socketIsOpen is True your programm will be using a lot of

Categories : Python

Create a custom server control with nested optional controls
tl;dr I ended up using the MultiView control. It doesn't allow duplicate IDs but it satisfies all my other requirements and it allows me avoid having to maintain any custom code. What I tried I was finally able to get something working with this code: using System.Collections.Generic; using System.Linq; using System.Web.UI; namespace CustomControls { [ParseChildren(true)] [PersistChildren(false)] public class VersionedContent : Control { public string VersionToUse { get; set; } [PersistenceMode(PersistenceMode.InnerProperty)] [TemplateContainer(typeof(ContentContainer))] [TemplateInstance(TemplateInstance.Multiple)] public List<Content> ContentVersions { get; set; } public override ControlCollection Controls

Categories : C#

jQuery menu open after page load, should start out closed
$('.hidden').slideUp(1).delay(2000).slideDown('slow'); This is just a prototype integrate with your code .. JSFIDDLE DEMO

Categories : Javascript

"launchctl start error: Bad file descriptor" when trying to start Neo4j server
I had to remove it from launchd and then it would work, like this: balinjdl-mac:local balinjdl$ neo4j start WARNING! You are using an unsupported version of the Java runtime. Please use Oracle(R) Java(TM) Runtime Environment 7. Using additional JVM arguments: -server -XX:+DisableExplicitGC Dorg.neo4j.server.properties=conf/neo4j-server.properties Djava.util.logging.config.file=conf/logging.properties Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC XX:+CMSClassUnloadingEnabled -Dneo4j.ext.udc.source=homebrew Detected installation in launchd, starting it... launchctl start error: Bad file descriptor balinjdl-mac:local balinjdl$ neo4j remove balinjdl-mac:local balinjdl$ neo4j start WARNING! You are using an unsupported version of the Java runtime. Please use Oracle

Categories : Osx

How to create DVD Video with closed captioning?
http://latentimagedesign.com/ClosedCaptionCreator/create.php You can load your srt file and export as an adobe XML file. Use adobe CC to convert the XML file to SCC for DVD authoring or embed the closed caption file.

Categories : Misc

Get HTML control in formview control on server
If you added html controlls with runat="server" you can access it with Request.Form[ControlName.UniqueID] otherwise, you need to add name="yourcontrol" and you will get the controls in Request.Form["YourControlName"].

Categories : Asp Net

TCP server socket is closed if i switched to another app
In android, the decision whether to keep your app running or not depends a lot on the existence of a Context whether it is an Activity, Service or BroadcastReceiver. According to android's documentation: An empty process is one hosting no activities or other application components (such as Service or BroadcastReceiver classes). These are killed very quickly by the system as memory becomes low. For this reason, any background operation you do outside of an activity must be executed in the context of an activity BroadcastReceiver or Service to ensure that the system knows it needs to keep your process around. So what do you want to do is starting a service once your activity is started and from that service spawn a thread that will manage the TCP server. that way you will be fine as l

Categories : Java

When should SQL server connection be closed in a script?
You don't have to do them at all. After header('Location... you should use exit immediately. Open connections are closed when the script exits automatically. You could manually close them and use exit after that, though. You only need to worry about manually closing the connections if you're running out of connections during long-running scripts, but you may have other problems at that point.

Categories : PHP

.NET SQL Server connection being prematurely closed
The simplest thing to do would be to check the connection state and open it if necessary: if(conn.State == ConnectionState.Closed)//Can't quite remember the exact syntax { conn.Open(); } //do DB stuff here.

Categories : Sql Server

I try to create a build in ant were it create a html report which will start my .class file
Try the following build.xml. Please keep it in mind the following change you need to do manually in this file Project name in very first line lib.dir address should be the one where all of your jars are kept physically. I suggest create a dir, put all the jars in this and give the address over here. the report directory I have changed and now it is under the project directory, parallel to src. If you need you can change it. Please note that I have changed my build.xml having many other features to the one you are comfortable. I have updated it very carefully, though very few changes may left by mistake that I suppose you can do. still if you found any problem, I would love to help you as far as I can. <project name="ProjectName" basedir="."> <property name="home.dir"

Categories : Java

SQL Server session stays open when application is closed
Entity framework uses the underlying SQL Server ADO.NET provider which pools database connections as they are an expensive operation to create and flush each time. You can flush the connection pool using a SqlConnection.ClearPool method call on your Application_End event handler. Note: I would not recommend disabling or flushing the connection pool for production code. An alternate method for development can be to modify to disable pooling via you connection string using the Pooling=false option.

Categories : C#

Fatal: Server unexpectedly closed network connection
The command is working fine for me. However, your question suggests that you're trying to connect to an FTP server. WinSCP can handle both SCP/SFTP and FTP connections, but to my knowledge psftp supports only SFTP (a file transfer protocol based on SSH, not to be confused with FTPS). If your server is not an SSH server, you need an FTP client for the data transfer (e.g. ftp.exe shipped with Windows). If your server is an SSH server, try running psftp with the option -v to get more information, and also check the logs on the server.

Categories : Powershell

application crashes if the server is closed due to timeout. How can I catch it?
Please try the following public String getData(String url) { HttpClient httpclient = new DefaultHttpClient(SetHttpParams.setHttp( 50000, 50000)); HttpGet httpget = new HttpGet(url); HttpResponse response; try { response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() == 200) { org.apache.http.HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); String res = Functions.convertStreamToString(instream); } } } catch (ConnectTimeoutException e) { } catch (SocketTimeoutException e) { } catch (IOException ex) { } } String res is your string where the response will be stored

Categories : Android

determine if client has closed connection to server using socket
Here is some code I believe can be used to detect exiting socket... Originator of this code was stated as Andrew Gillard no other licence information was available... <?php $host = '127.0.0.1'; $port = 7010; gc_enable(); set_time_limit(0); function socketError($errorFunction, $die=false) { $errMsg = socket_strerror(socket_last_error()); echo $errorFunction.' '.$errMsg." "; if ($die) die("Program Ended "); } //Attempt to create our socket. The "@" hides PHP's standard error reporting, if (!($server = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) socketError('socket_create', true); //socket_set_option($server, SOL_SOCKET, SO_REUSEADDR, 1); if (!@socket_bind($server, $host, $port)) socketError('socket_bind', true); if (!@socket_listen($server)) socketError('socket_list

Categories : PHP

Server dies on `send` if client was closed with Ctrl+c
When you call send() on an already closed connection, the operating system may issue SIGPIPE to your process. Usually the default handler for SIGPIPE is to kill your process. In order to prevent this from occurring, you can either ignore the signal (e.g., with signal(SIGPIPE, SIG_IGN) or sigignore(SIGPIPE)), or you can pass the MSG_NOSIGNAL option to send(): int send_result = send(newfd, ok, 3, MSG_NOSIGNAL); if (send_result >= 0) { /* okay, but check if all your data got sent! */ if (send_result < 3) /* ...do something */; } else { switch (errno) { /* ... */ case EPIPE: /* sending on a closed connection... */ } } Now, instead of issuing SIGPIPE, the send() call will fail, and errno will be set to EPIPE.

Categories : C

WPF : Animating Width of an Control alternately with start value
Do you explicitly need to set the Visibility to Hidden if you're setting the Width to 0? A zero-width element and a hidden element look the same onscreen. Your exit action is not being 'hidden', what's happening is the DataTrigger is 'undoing' the <Setter Property="Visibility" Value="Visible"/> in addition to running the exit action. But since the visibility has immediate effect you don't see the exit action being run. Your enter action needs to both Visibility=Visible and start the expanding animation. Your exit action needs to perform the shrinking animation, but wait to set Visibility=Visible until after it's complete. You can do this with an ObjectAnimationUsingKeyFrames animation: <Image.Style> <Style TargetType="Image"> <Setter Property="Visibil

Categories : Wpf

eclipse can not start up my tomcat server, how to turn the server on
It seems your sever is already in running state and you are trying to start again. Any chance you started your server though comand prompt, before trying in eclipse. If exsist try kiiling the java process of the server in task manager and try again

Categories : Java

Catch the exception thrown at client side when the server closed the pipe
the most common way to know that the other side is dead is the "echo": once in a while(let's say every 10 seconds) the client sends an "echo" - meaning a simple request to the server to get replay. if 3 echo in a row(could be more, depend on you) did not answered by the server, the client decide that the server is down and disconnect his side

Categories : C#

Client prints Half Data Before Connection is Closed By Server on Socket
try flush data after sent. it needs if you use socket with fdopen FILE *fdsock = fdopen(sock, "a+"); ... fwrite(fdsock, 1, 1 "A"); fflush(fdsock); ... fclose(fdsock); and to finish socket, close with shutdown(sock, SD_SEND); UPDATE Take memset out of loop

Categories : C

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

How to control start level of bundles deployed from pickup directory?
You can only restrict the resolution of bundles to the availability of capabilities, but not the activation. Activation certainly happens after resolution, but resolved bundles may be activated in any order. So bundle-level activation dependencies don't work well. Instead, you should use "components" (i.e. declarative services) which have the option to bind their lifecycle to the availability of other components. With this option, the bundles may start in an arbitrary order, but services are still only activated/exposed once all its service dependencies are activated.

Categories : Misc

find a control with no runat='server' from server side
You could do conversationdiv.InnerHtml... in this specific case it would return the HTML of the table. You could then use HTML Agility Pack to query or manipulate the said table. Example var html = new HtmlAgilityPack.HtmlDocument(); html.LoadHtml(conversationdiv.InnerHtml); var table = html.DocumentNode.SelectNodes("table").FirstOrDefault(); var tr = table.SelectNodes("tr").FirstOrDefault(); var td = tr.SelectNodes("td").FirstOrDefault(); var blahBlah = td.InnerText;

Categories : C#

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

create a batch to open iexplore and close another process after iexplore is closed
You could loop until there are no more iexplore.exe processes: :loop tasklist /fi "imagename eq iexplore.exe" /nh | find /i "iexplore.exe" if %errorlevel% equ 0 ( ping -n 2 127.0.0.1 >nul goto loop ) The ping is for waiting 1 second before trying again (on Win7 you can replace it with the timeout command). However, I think you'd be better off using a more versatile scripting language.

Categories : Internet Explorer

Using VBA cell reference to create external reference to closed workbooks
You can certainly use the Index/Match functions to reference closed workbooks, e.g.: Use index/match to find "steve" in column A of a closed workbook named "Test.xlsx" and return the value in corresponding row, column B: =INDEX('C:Usersdavid_zemensDesktop[test.xlsx]Sheet1'!$A$1:$B$1,MATCH("steve",'C:Usersdavid_zemensDesktop[test.xlsx]Sheet1'!$A:$A,FALSE),2) Obviously, you could change the *lookup_value* of "Steve" to anything, including a cell reference.

Categories : Vba

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

Heroku and NodeJs - MySql Connection lost: The server closed the connection
You already seem to know what is happening; the MySQL server is closing the connection. Many database services, including ClearDB, to do this (ie, close inactive connections). You're going to have to detect the disconnect event, and recreate the connection. There are instructions in the node-mysql documentation for doing this.

Categories : Mysql

How can I create and start an Intent?
You can try with this : Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra("Data", "Test printer "); sendIntent.setComponent(new ComponentName("qsrtech.posprintdriver","qsrtech.posprintdriver.printservice")); startService(sendIntent);

Categories : Java

Node.js + setInterval = Connection lost: The server closed the connection
Looks like you're keeping an open connection to a remote MySQL server. The remote server is closing the connection after 8 hours of idle connection. So you have two options. Either you send a keepalive request or you disconnect after your initial request and then open the connection again when timer initiates the next event. Keepalive If you want to send a keepalive request, simply setup a select 1 on an interval timer. select 1 is just a simple query that will cause MySQL to return a result of 1 and reset the MySQL server's connection timeout. It would look something like this. function keepalive() { connection.query('select 1', [], function(err, result) { if(err) return console.log(err); // Successul keepalive }); } setInterval(keepalive, 1000*60*5); Pooling Howeve

Categories : Javascript

how to create timer thats start automatically?
I want to have a automatic timer which start when we enter in this activity. And on next round its start again from some time and goes on decreasing. i know for this i have to create textview in question xml related to this call. but i dont know where and how to write code in this class. timer time 30 sec. You can achiev this using CountDownTimer new CountDownTimer(30000, 1000) { public void onTick(long millisUntilFinished) { mTextField.setText("seconds remaining: " + millisUntilFinished / 1000); } public void onFinish() { mTextField.setText("done!"); } }.start(); For more info refer here

Categories : Android

Selenium server start within .NET
I can start sever with this command "java -jar selenium-server-standalone-2.33.0.jar -trustAllSSLCertificates" from command line and C# code. Server starting well i can create driver and can see the page source . IWebDriver driver = new RemoteWebDriver(new System.Uri("http://loclhost:4444/wd/hub"), DesiredCapabilities.Opera()); driver.Navigate().GoToUrl(url); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(100)); But when i want to reach WebElement through this code element throws lots of exception ('element.Displayed' threw an exception of type 'System.InvalidOperationException') IWebElement element; // FindElement(driver, "txtUserName", 100); element = driver.FindElement(By.Id("txtUserName")); string name = element.GetAttribute("Name");

Categories : C#

Can't start rabbitmq-server
{"could not start kernel pid",application_controller,"error in config file "/etc/rabbitmq/rabbitmq.config" (none): no ending found"} you have invalid config no ending found IOError: [Errno 13] Permission denied: 'src/rabbit_framing_amqp_0_9_1.erl' you don't have a permission to write to file, run make with sudo or change destination directory

Categories : Ubuntu

can't start ruby server
Check your YAML config files, you probably have a typo in one of them. This can help you debug your YAML files: http://yaml-online-parser.appspot.com/

Categories : Ruby On Rails

Cannot start brunch server
I figured it out with my senior programmer. It turns out I didn't have build-essential package install on my ubuntu. It was looking for g++ command. Likewise when I do a npm install, it needs sudo. After the g++ fix and the sudo npm install, I was able to launch brunch w -s

Categories : Ember Js

Not able to start Infinispan server
I saw you already got it work. (https://community.jboss.org/message/828728) It didn't work for you after changing /etc/security/limits.conf numbers because changes in this file are applied after re-login. For other people with this problem, please, see https://docs.jboss.org/author/display/ISPN/Contributing+-+The+test+suite, set your limits accordingly and re-login. Check your limits using ulimit -a

Categories : Java

How to start adb server over tcp programmatically
You need root access to do this. It would be a huge security issue otherwise. You can use a library like libsuperuser to run root commands. Example using libsuperuser: String[] commands = { "setprop service.adb.tcp.port 5555", "stop adbd", "start adbd" }; Shell.SU.run(commands); // Get the WiFi IP address WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int ip = mWifiManager.getConnectionInfo().getIpAddress(); String wifiIp = (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + ((ip >> 24) & 0xFF); // Tell the user what the next step is. Toast.makeText(context, String.format("Run 'adb connect %s:5555' in terminal/command-prompt", wifiIp), Toast.LENGTH_LONG).show();

Categories : Android

MongoDB server won't start
Okay, I've figured it out by scanning journalctl output: ul 09 19:49:33 arch mongod[1122]: all output going to: /var/log/mongodb/mongod.log Jul 09 19:49:33 arch mongod[1122]: can't open [/var/log/mongodb/mongod.log] for log file: errno:13 Permission denied Jul 09 19:49:33 arch mongod[1122]: Bad logpath value: "/var/log/mongodb/mongod.log"; terminating. So I searched for user that might be utilized by mongodb: jan@arch:~$ cat /etc/passwd root:x:0:0:root:/root:/bin/bash ... mongodb:x:998:2::/var/lib/mongodb:/bin/bash And chowned required folders: jan@arch:~$ sudo chown -R mongodb:x /var/log/mongodb/ jan@arch:~$ sudo chown -R mongodb:x /var/lib/mongodb/ Started it again: jan@arch:~$ sudo systemctl start mongodb It works now. jan@arch:~$ mongo MongoDB shell version: 2.4.5

Categories : Mongodb

Tomcat server could not start
Sounds to me as if you're doing this inside Eclipse with WTP? If so then you need to make sure that the Eclipse project called Servers which is created and maintained by WTP is open. Open the Navigator view Locate the Servers project right-mouse click Open Project

Categories : Java

Run a PHP script on server start
As a solution to your specific problem use bash script to execute PHP cli Pusedo code will be usrsbinphp -q homeusermyphpscript.php this will execute the PHP script without any time constrain, however since you use PHP CLI you might not get some environment variables, which are web specific, but for such background process you hardly need them anyways.

Categories : PHP

How to create a Java game start screen?
I see... A JPanel acting as the primary container for the splash screen A JLabel to hold the background image A JButton for the user to click. I also see a CardLayout to help make it easier to switch between your SplashScreen and your Game screen. Check out How to use CardLayout for more details. From your description, it sounds like you've started by overriding paint of the JApplet class. Welcome to the wonderful world of "Why you shouldn't override paint of a top level container" You need to move all you custom painting and control logic to a different component (something like a JPanel would do) and use it's paintComponent method instead. This way, you can control where the panel goes (could be made into a stand alone application) and provide support for swappable screens/panes

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.