w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Connecting C socket server from PHP using PHP Extension
Debug your code properly, could you receive parameters in your C Client code passed from PHP function call, I hope you will not get the parameters which you are passed from PHP function call. Check your parameters receive section, there you have to check the type of values sending from PHP should match the type of declaration in your C Client socket connection scripts. I hope replace your receive parameters section with my following code, it will work. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|b", &i_iPortNumber, &i_pcIPAddress, &return_long) == FAILURE) { RETURN_NULL(); }

Categories : PHP

FATAL EXCEPTION MAIN on socket based client/server app
Caused by: android.os.NetworkOnMainThreadException You're doing networking on the main thread. Move the networking code to another thread using AsyncTask. That should be a sufficient wrapper around threading for your needs.

Categories : Java

UNIX SOCKET - direct write into socket's memory possible?
The socket buffer is owned by the kernel, you will never be allowed to write into kernel space. Never, ever. Too much of a security risk. The only way to do zero-copy is to use vmsplice(2), but it is not officially supported for sockets and is not recommended to use for anything other then pipes. If you do decide to use vmsplice, keep in mind that you must then commit your data in chunks of pages sysconf(_SC_PAGESIZE). Also it is a Linux only syscall and not portable.

Categories : C

Connecting to a udp socket in Node.js
You need to use the addMembership() method to join a multicast group, in UDP you don't connect to servers, a connection is never created and there is no guarantee that you will receive any/all packets. You join a multicast group and receive packets with that group-id that reach your network card, the python method name is misleading. http://nodejs.org/api/dgram.html#dgram_socket_addmembership_multicastaddress_multicastinterface

Categories : Python

Dojox socket exception with node.js socket.io
Seems to be an unresolved ticket for a while https://bugs.dojotoolkit.org/ticket/16572 edit: https://github.com/dojo/dojo/commit/3beccffc21fbcd3e21681fc74a29b0c56a31572f

Categories : Javascript

Synchronously connecting to a socket in node js
After adding the missing "require" statements and the server.listen() call to get the script to run, it works fine for me: var http = require('http'); var Socket = require('net').Socket; var server = http.createServer(function(req, res){ var sock = new Socket(); sock.connect(80, "www.google.com", function(){ console.log("Connected to google.."); sock.write("GET / "); }); sock.on("data", function(data){ console.log(data.toString()); res.writeHead(404, {"Content-type": "text/plain"}); res.write(data, "binary"); res.end(); sock.end(); }); sock.on("end", function(){ console.log("Disconnected from socket.."); }); }); server.listen(8080);

Categories : Javascript

socket.io error when connecting from iframe
You have encountered Same Origin Policy. The simplest solution is to run the iframe from the same server. Since you have access to I.T time read up on CORS You will basically have to configure the server to allow XSS from your domain. You can also try something like: document.domain = "intranet" Read up on it here

Categories : Javascript

PULL socket not connecting fast enough to ROUTER
Why is this happening? You have a race condition. The client1.connect call starts the connection process, but there is no guarantee the actual connection is established when you call rtr.sendMore("client1");. Your sleep() workaround pretty much proves this. Changing PULL to DEALER is a step in the right direction, because DEALER can send and receive. In order to avoid the need for sleeps and waits you would have to change your protocol. A simple change to the code above would be to have the DEALER connect and then immediately send a "HELLO" message to the ROUTER (could be just an empty message). The router code must be redesigned such that it does nothing until it receives a HELLO message from the DEALER. Once you have received the HELLO message you know the connection is succes

Categories : Java

How to receive web socket message from server in client side by html5 socket api
Its always good practice before connecting to websockets, to check if the browser your user is using supports them....like so.... //First check for firefox, and set it to regular websocket...since Mozilla API is differently named if (window.MozWebSocket) { window.WebSocket = window.MozWebSocket; } //Then continue with checking var connection = {}; function connect() { if(window.WebSocket != undefined) { if(connection.readyState === undefined || connection.readyState > 1) { connection = new WebSocket('ws://127.0.0.1:80'); } } }

Categories : PHP

iOS Client connecting to NodeJS socket.io results in Stream end encountered
Turns out that socket.io has its own authentication protocol and is not compatible with SocketRocket out of the box. See this SO answer: How to use SocketRocket with socket.io? From the answers there, you could take a look at socket.io-objc

Categories : IOS

NodeJS Dynamically Load server instancess for a socket using socket.io
You are exporting a function, and not an object. This means that the correct call should be sv(io) and not sv.init(io). If you want to expose the init function, you have to use module.exports.init = init.

Categories : Javascript

Java Socket server not recieving data from client socket
Your client doesn't close the socket. Your server reads the socket until EOS, which will never arrive as your client doesn't close the socket. NB don't handle client I/O in the accepting thread. Start a separate thread.

Categories : Java

Socket Connecting and Sending Data Received but not read on ASP.net side from Android
The Read() call on the netStream fills the data into the rcvBuffer, but then you try to get your string from the data buffer... and you read two times before you try to get the string, once before the while and once inside the while. Maybe you can use a do{}while() loop.

Categories : C#

Node.js terminates execution before script is finished, connecting via socket.io-client
I'd start by seeing if socket.io is throwing any errors: socket.on('error', function (exception) { console.log(exception); }); I'd also look to see if you're connecting to the right port. It's probable that the remote socket.io server is not on a default port.

Categories : Node Js

How to make client socket wait for server socket
boolean scanning=true; while(scanning) { try { socketChannel.open(hostname, port); scanning=false; } catch(ConnectionException e) { System.out.println("Connect failed, waiting and trying again"); try { Thread.sleep(2000);//2 seconds } catch(InterruptedException ie){ ie.printStackTrace(); } } } This is the code for sonics comment

Categories : Java

Chat client - Socket and server socket concurrently
ServerSocket blocks and that's it. But if you only want peer-to-peer communication between two connected parties and nothing more then this behavior is not a problem. You just need two programs: server and client. Server block until it gets connection from client and client blocks until it gets connection. If you want to implement Java IO in single thread you should use Java Nio. There are lots of tutorials for that in internet. For example http://tutorials.jenkov.com/java-nio/server-socket-channel.html. Also it seems that you are not very familar with networking and sockets so it might be beneficial to use some layer instead of raw sockets. Maybe you should consider JeroMQ (https://github.com/zeromq/jeromq) for implementing communication between programs.

Categories : Java

Abrupt termination of server (Socket operation on non-socket)
This is actually a linux problem, because you're trying to use recv and send to read from and write to STDIN (which is probably a terminal not a socket). Unlike most UNIX variants, in Linux, send and recv can only be used on sockets, not on any file descriptor. For a terminal, you need to use read and write. There's also the issue that it's weird to write to STDIN -- normally you only read from STDIN and write to STDOUT. But as long as STDIN is somethine like a terminal you can write to, it would be ok.

Categories : C

First-chance exception at 0x76F8277C in SensorTest.exe: Microsoft C++ exception: Platform::COMException ^ at memory location
You can't test gyroscope code on the Windows Phone emulator at this time. See http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202943(v=vs.105).aspx. Important Note: You cannot test this app on the emulator. The emulator doesn’t support the gyroscope. You can only test this app on a registered phone. Also beware that not all Windows Phones have gyroscope hardware.

Categories : C++

Batch File Connecting to Server and execute program install on connected server
Here's a little code to help you connect to the SQL server and interrogate the SQL version. @ECHO OFF SQLCMD /? > nul 2> nul IF ERRORLEVEL 1 ECHO.SQLCMD not found on this machine & PAUSE & GOTO :eof SET SQLCmdLine=SQLCMD -b -w400 REM use something like the next line for NT authentication; second line for SQL authentication REM for NT SET SQLCmdLine=%SQLCmdLine% -E -S "YourServerName" REM for SA SET SQLCmdLine=%SQLCmdLine% -U "YourSQLUserName" -P "YourSQLPassword" -S "YourServerName" SET Database=YourDatabaseName REM I will use NT Authentication for this example SET SQLCmdLine=%SQLCmdLine% -E -S "(local)" SET TestSQLCmdLine=%SQLCmdLine% -h-1 -d "%Database%" REM this will get the SQL version %TestSQLCmdLine% -Q "SELECT @@VERSION" | FINDSTR /v "rows affected" REM this will

Categories : SQL

sqlsrv error while connecting to mssql server 2008 on windows 2003 server
Two ways to try, first to check if the Native driver has the right version - is your server really a 32bit Version and not 84bit? The other thing is, to check if the extensions are actually loaded. To check that, create a file like "phpinfo.php" and put it in you folder for .htdocs. <?php // show phpinfo file phpinfo(); ?> The easy way is to search for it in the phpinfo-Page with Ctrl+F and "extension=php_sqlsrv_53_ts_vc9.dll"

Categories : PHP

Clearing heap memory for Out of Memory Exception
After 3 days of struggle i found a solution for not increasing Heap memory by using this i replace all my ImageView like this <com.example.util.SingleShotImageView android:id="@+id/grid_image" android:layout_width="170dp" android:layout_height="240dp" android:adjustViewBounds="true" android:layout_centerInParent="true" /> Using this class i use to clear the Image bitmap heap size in onDetachedFromWindow function public class SingleShotImageView extends ImageView { public SingleShotImageView(Context context) { super(context); } public SingleShotImageView(Context context, AttributeSet attrs) { super(context, attrs); } pub

Categories : Android

Exception while connecting to DB2 in java using JDBC
Cause: If the DB2® instance where InfoSphere Optim Performance Manager is running has the authentication configuration parameter set to DATA_ENCRYPT, you cannot log in to the web console. Resolving the problem: Do the following steps: On the DB2 instance where Optim Performance Manager is running, set the authentication configuration parameter to SERVER by issuing the following command: db2 update dbm cfg using authentication server Restart the DB2 instance and InfoSphere Optim Performance Manager. For more details visit here.

Categories : Java

Exception in connecting to DB2 source using Java JDBC driver
You will have to use a SecurityProvider. BouncyCastleProvider can be a good option for you. All you have to do is, as a first step in getConnection() method use below line: Security.addProvider(new BouncyCastleProvider());

Categories : Java

Exception connecting to Remote Solr Instance (407 error)
HTTP code 407 implies Proxy Authentication Required, you need to set authentication information while making connection to server via HttpClient: httpclient.getCredentialsProvider().setCredentials( AuthScope.ANY, new UsernamePasswordCredentials(username, password)); solrServer = new HttpSolrServer(solrUrl, httpclient);//with credentials you may like to check similar discussions: Solr - instantiate HttpSolrServer with Httpclient Solr 4 with basic authentication

Categories : Java

Exception Connection refused while connecting Android device to PC
You are trying to access http://localhost:8080/project-server/rest/?value=test, but localhost refers to the loopback address 127.0.0.1, so your request is sent to your Android device itself, not to your pc. Change localhost with the ip address of your pc.

Categories : Java

How to handle socket read in C when the remote server closes socket possibly before read is finished?
TCP treats the connection serially, and the reader processes everything in the order that the sender transmitted. When the sender closes the connection, the reader will get an EOF after it has read all the data that was sent, not before.

Categories : C

Socket won't release the memory
Class Sockets implements interface IDisposable, so it's preferable to use using statement i.e. using(Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { sck.Connect(new IPEndPoint(IPAddress.Parse(ipAdd), 3152)); sck.Send(bytesSent, SocketFlags.None); Thread.Sleep(10); sck.Shutdown(SocketShutdown.Both); sck.Close(); bytesSent = null; }

Categories : C#

Entity Framework 6 in Mono 3.0.10 connecting SqlServer throws a Provider Incompatible Exception
I did the same thing and got the same error. My solution was to compile EntityFramework from the source (Codeplex, version 6.1.0alpha) and change a line of code in SqlProviderManifest.cs private static XmlReader GetXmlResource(string resourceName) { //return XmlReader.Create(typeof(SqlProviderManifest).Assembly().GetManifestResourceStream(resourceName), null, resourceName); return XmlReader.Create(typeof(SqlProviderManifest).Assembly().GetManifestResourceStream(resourceName), null, String.Empty); } Not nice, but solved my problem until I tried some really weird lamba query or tried to write something to the database.

Categories : Sql Server

Client-Server: File transfer from Android to PC connected via socket And Response from server
Gustavo, The transfer is done well, but as long as the server don't know how much data you are sending it waits in the read loop until you close the socket or a timeout occurs. In order to let the server knows you have sent the whole data the socket must be shut down for output, with this, the server will received that indication, read() returns 0. Then the server will send the 99 message to the client. For example: at the server: int ret=0; int offset=0; byte[] mybytearray = new byte[filesize]; while ((ret = is.read(mybytearray, offset, filesize -offset)) > 0) { offset+=ret; // just in case the file is bigger that the buffer size if (offset >= filesize) break; } bos.write(mybytearray, 0 , offset); bos.flush(); long end = System.currentTimeMilli

Categories : Android

Haskell socket programming - Memory leaks
I've just spoke to an colleague and he told me that the problem is this section loop sock (sockId + 1) I'm buildung up thunks without ever evaluting, which definitely fills up the heap. I hope this helps other people facing similiar problems.

Categories : Networking

Socket I/O directly into a .NET memory mapped file?
Clearly Keith deserves credit for pointing me in the right direction, but to summarize the answer: what would work best for me is to write a little module in C or C++, compile it to create a DLL that would be part of my assembly, and load it (this can be done dynamically or statically; latter is easier of course). I can then call from C# into C and my C code can just do the raw system calls using true addresses. Since memory-mapped files (even the ones with no persistent storage) don't move around due to garbage collection or consolidation, this is an unusually easy case. In fact the C code doesn't even need to learn the address from the C# code -- it can just "remap" the same file, although passing the address should be easy enough. Moreover, this can be just as portable as my origina

Categories : Dotnet

There is no timeout exception in socket
You need to set the timeout for the socket if you wan to have one: ... client, address = server.accept() client.settimeout(10) ... Or you can use a default timeout for all sockets. socket.Timeouterror doesn't exist, it should be socket.timeout. Also, you probably should close the client socket, otherwise the client will not know that the connection is closed. The timeout alone doesn't do that for you.

Categories : Python

Exception thrown when connecting Neo4j+HA and Spring Data- "Missing Mandatory Setting ha.initial_hosts"
The config of bean haDatabase is incomplete. Neo4j 1.9.x does not use ha.coordindator, use ha.initial_hosts instead. ha.coordinator was used up to 1.8.x.

Categories : Neo4j

Connecting to a SQL Server DB
Well this seems to work ok, use DBI; # $dbh = DBI->connect( "dbi:mysql:DBNAME", "root", "password" ) or die "Connection Error $DBI::errstr "; N.B. Please Check you have the required modules installed.

Categories : Perl

Can a descriptor created by socket() be mapped to a memory buffer?
Is there a way to map a descriptor created by socket() to a memory buffer? No. It doesn't make sense. A mapped file makes sense because of the virtual memory system. A mapped socket doesn't. I want to map a fd returned by the application to a buffer I created. You will have to write code to read from the socket into your buffer.

Categories : Sockets

Socket.io memory doesn't drop of after clients disconnect
I've had similar issues with socket.io. It seems that once a client connects, it never gets deleted from socket.io. You can debug the value of SocketIoServer.sockets.sockets. It is an array containing all connected (and disconnected sockets). Maybe that's where your memory leak lies. Also, I just saw that socket.io released version 1.0. You can try it out and see if it has resolved that issue.

Categories : Node Js

VB Socket Exception Issue - Ports
Along the lines of Hans's comment, you are probably calling serverMode more than once through the life of your program. The one thing I noticed is that in your finally block you are not calling .Stop on your server, which means its possible to exit serverMode without shutting it down. Once that happens, repeated calls to start the server will likely fail.

Categories : Vb.Net

Socket exception when I install UnityVS
This is a small bug in UnityVS 1.2. The good news is that it is fixed in 1.8. This doesn't impact the ability to debug your game. It simply means that we failed to announce the editor existence over multicast for the remote debugging scenario. Everything local will work just fine.

Categories : Visual Studio 2010

Connecting Sql Server though Node.js
I just did it following this walkthrough at http://tech.pro/tutorial/1848/getting-nodejs--sql-server--azure-to-work-together He's using the "msnodesql" package at https://www.npmjs.org/package/msnodesql, code at git-hub at https://github.com/WindowsAzure/node-sqlserver, and I've got it running in a node-console app with a simple select-statement: var mssql = require('msnodesql'); var conn_str = "Driver={SQL Server Native Client 10.0};Server=tcp:xxxxx;Database=yyyy;Uid=zzzz;Pwd=wwww;Connection Timeout=30;"; mssql.query(conn_str, "select * from testtable", function(err, recordset) { if(err){ console.log("Got error :-( " + err); return; } recordset.forEach(function(record) { console.log("name: " + record.Name + " (" + record.ID + ")"); }); });

Categories : Sql Server

connecting to an SQL Server database
The problem your having with regards to connecting to the database on a server is because of SqlConnection dbConnection = new SqlConnection("Data Source=.\SQLEXPRESS;Integrated Security=true"); The best way to do this is to go to your Web.config file and find the block and add a connection to your database in there. eg <add name="ConnectionString" connectionString="Data Source=YOUR SERVER;Initial Catalog=YOUR DATABASE;User ID=YOUR USER ID;Password=YOUR PASSWORD" /> then you can just call the connection string accross your whole project whenever you need to use it. Also with regards to VS2012. There are very few companies using that IDE at the moment so your probably better off learning VS 2010 in the most part but i would agree that VS2008 is fairly out of date now

Categories : C#



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