Search Results

Search found 5206 results on 209 pages for 'dr rocket mr socket'.

Page 4/209 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Socket Read In Multi-Threaded Application Returns Zero Bytes or EINTR (104)

    - by user309670
    Hi. Am a c-coder for a while now - neither a newbie nor an expert. Now, I have a certain daemoned application in C on a PPC Linux. I use PHP's socket_connect as a client to connect to this service locally. The server uses epoll for multiplexing connections via a Unix socket. A user submitted string is parsed for certain characters/words using strstr() and if found, spawns 4 joinable threads to different websites simultaneously. I use socket, connect, write and read, to interact with the said webservers via TCP on their port 80 in each thread. All connections and writes seems successful. Reads to the webserver sockets fail however, with either (A) all 3 threads seem to hang, and only one thread returns -1 and errno is set to 104. The responding thread takes like 10 minutes - an eternity long:-(. *I read somewhere that the 104 (is EINTR?), which in the network context suggests that ...'the connection was reset by peer'; or (B) 0 bytes from 3 threads, and only 1 of the 4 threads actually returns some data. Isn't the socket read/write thread-safe? I use thread-safe (and reentrant) libc functions such as strtok_r, gethostbyname_r, etc. *I doubt that the said webhosts are actually resetting the connection, because when I run a single-threaded standalone (everything else equal) all things works perfectly right, but of course in series not parallel. There's a second problem too (oops), I can't write back to the client who connect to my epoll-ed Unix socket. My daemon application will hang and hog CPU 100% for ever. Yet nothing is written to the clients end. Am sure the client (a very typical PHP socket application) hasn't closed the connection whenever this is happening - no error(s) detected either. Any ideas? I cannot figure-out whatever is wrong even with Valgrind, GDB or much logging. Kindly help where you can.

    Read the article

  • SocketTimeOutException while creating socket, java

    - by Sunil Kumar Sahoo
    Hi All, I have created a sample java socket application. I used Socket s = new Socket(ip, port) Now it works fine. but when my internet connection is very slow that time after a long interval (even if sometimes after 2 minutes) i used to get SocketTimeOutException in that line. means it gives that error while creating socket. I want the exception should be handled properly means if internet connection is very slow then if that error occurs it happens very late now . I want if this type of error occurs then it should be caught very fast means the error should not come at such a delay interval of time rather it should come immediately. How to achieve this. Thanks Sunil Kumar Sahoo

    Read the article

  • Java Socket Programming

    - by Bapi
    Java Socket Program did not work for WAN I have written a TCP IP socket program which works fine in my LAN. One of my friend is at bangalore He ran the server and I ran the client with the host name of my friend's IP. In this case my socket program did not work.

    Read the article

  • Python socket error on UDP data receive. (10054)

    - by Charles
    I currently have a problem using UDP and Python socket module. We have a server and clients. The problem occurs when we send data to a user. It's possible that user may have closed their connection to the server through a client crash, disconnect by ISP, or some other improper method. As such, it is possible to send data to a closed socket. Of course with UDP you can't tell if the data really reached or if it's closed, as it doesn't care (atleast, it doesn't bring up an exception). However, if you send data and it is closed off, you get data back somehow (???), which ends up giving you a socket error on sock.recvfrom. [Errno 10054] An existing connection was forcibly closed by the remote host. Almost seems like an automatic response from the connection. Although this is fine, and can be handled by a try: except: block (even if it lowers performance of the server a little bit). The problem is, I can't tell who this is coming from or what socket is closed. Is there anyway to find out 'who' (ip, socket #) sent this? It would be great as I could instantly just disconnect them and remove them from the data. Any suggestions? Thanks.

    Read the article

  • Socket Read In Multi-Threaded Application Returns Zero Bytes or EINTR (-1)

    - by user309670
    Hi. Am a c-coder for a while now - neither a newbie nor an expert. Now, I have a certain daemoned application in C on a PPC Linux. I use PHP's socket_connect as a client to connect to this service locally. The server uses epoll for concurrent connections via a Unix socket. A user submitted string is parsed for certain characters/words using strstr() and if found, spawns 4 joinable threads to different websites simultaneously. I use socket, connect, write and read, to interact with the said webservers via TCP on port 80 in each thread. All connections and writes seems successful. Reads to the webserver sockets fail however, with either (A) all 3 threads seem to hang, and only one thread returns -1 and errno is set to 104. The responding thread takes like 10 minutes - an eternity long:-(. *I read somewhere that the 104 (is EINTR) suggests that ...'the connection was reset by peer', or (B) 0 bytes from 3 threads, and only 1 of the 4 threads actually returns some data. Isn't the socket read/write thread-safe? Otherwise, use thread-safe (and reentrant) libc functions such as strtok_r, gethostbyname_r, etc. *I doubt that the said webhosts are actually resetting the connection, because when I run a single-threaded standalone (everything else equal) all things works perfectly right. There's a second problem too (oops), I can't write back to the client who connect to my epoll-ed Unix socket. My daemon application will hang and hog CPU 100% for ever. Yet nothing is written to the clients end. Am sure the client (a very typical PHP socket application) hasn't closed the connection whenever this is happening - no error(s) detected either. I cannot figure-out whatever is wrong even with Valgrind or GDB

    Read the article

  • TCP Socket.Connect is generating false positives

    - by Mark
    I'm experiencing really weird behavior with the Socket.Connect method in C#. I am attempting a TCP Socket.Connect to a valid IP but closed port and the method is continuing as if I have successfully connected. When I packet sniffed what was going on I saw that the app was receiving RST packets from the remote machine. Yet from the tracing that is in place it is clear that the connect method is not throwing an exception. Any ideas what might be causing this? The code that is running is basically this IPEndPoint iep = new IPEndPoint(System.Net.IPAddress.Parse(m_ipAddress), m_port); Socket tcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); tcpSocket.Connect(iep); To add to the mystery... when running this code in a stand alone console application, the result is as expected – the connect method throws an exception. However, when running it in the Windows Service deployment we have the connect method does not throw an exception. Edit in response to Mystere Man's answer How would the exception be swallowed? I have a Trace.WriteLine right above the .Connect method and a Trace.WriteLine right under it (not shown in the code sample for readability). I know that both traces are running. I also have a try catch around the whole thing which also does a Trace.Writeline and I don't see that in the log files anywhere. I have also enabled the internal socket tracing as you suggested. I don't see any exceptions. I see what appears to be successful connections. I am trying to identify differences between the windows service app and the diagnostic console app I made. I am running out of ideas though End edit Thanks

    Read the article

  • AIX specific socket programming query

    - by kumar_m_kiran
    Hi All, Question 1 From SUSE man pages, I get the below details for socket connect options If the initiating socket is connection-mode, then connect() shall attempt to establish a connection to the address specified by the address argument. If the connection cannot be established immediately and O_NONBLOCK is not set for the file descriptor for the socket, connect() shall block for up to an unspecified timeout interval until the connection is established. If the timeout interval expires before the connection is established, connect() shall fail and the connection attempt shall be aborted. If connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to [EINTR], but the connection request shall not be aborted, and the connection shall be established asynchronously. Question : Is the above contents valid for AIX OS (especially the connection time-out, timed wait ...etc)?Because I do not see it in AIX man pages (5.1 and 5.3) Question 2 I have a client socket whose attributes are a. SO_RCVTIMEO ,SO_SNDTIMEO are set for 5 seconds. b. AF_INET and SOCK_STREAM. c. SO_LINGER with linger on and time is 5 seconds. d. SO_REUSEADDR is set. Note that the client socket is not O_NONBLOCK. Question : Now since O_NONBLOCK is not set and SO_RCVTIMEO and SO_SNDTIMEO is set for 5 seconds, does it mean a. connect in NON Blocking or Blocking? b. If blocking, is it timed blocking or "infinite" time blocking? c. If it is infinite, How do I establish a "connect" system call which is O_BLOCKING with timeout to t secs. Sorry if the questions are be very naive. Thanks in advance for your input.

    Read the article

  • Raw socket implementation in windows?

    - by krishnakumar
    I need to create TCP/IP headers manually for my application. For that i used Raw socket. My system os is win xp (SP3). My code compiles fine :) but it throws a run time error: Initialising Winsock...Initialised successfully. Creating Raw TCP Socket...Raw TCP Socket Created successfully. Setting the socket in RAW mode...Successful. Enter hostname : 192.168.1.152 Resolving Hostname...Resolved. Enter Source IP : 192.168.1.151 Sending packet... Error sending Packet : 10022 I have set IP_HDRINCL to 1. What am i doing wrong? I switched off the firewall too but still get the same result.

    Read the article

  • Generic socket 940 CPU fan for HP XW9300 interchangeable with HP part number 411454-001

    - by ConcernedOfTunbridgeWells
    Hi, I'm trying to find a generic Socket 940 CPU fan that will fit the air duct in an XW9300. Note that two different CPU fan mounting schemes have been used on this machine. One has two grommets in the motherboard that the CPU fan screws into and the other has a plastic collar and base plate. The form factor I'm looking for is the former (see the picture below). Two HP part numbers for fans in this form factor are 411454-001 (shown below) and 416055-001. Note that the dimensions are important as the machine has an air duct that fits over the fan. Can anyone tell me the manufacturer and model of an equivalent generic part? Better yet, do you know somewhere (preferrably in the UK) from which such an item can be obtained?

    Read the article

  • Centos 6.2, Apache 2 and Listen port for socket connection

    - by salvosav
    I'm trying to make a socket connection between a client and my server through a php script. To do this, I opened a port on iptables, and configure a virtual host with apache to redirect all traffic from my door to the folder that contains the file index.php, which is my script. Doing some tests the door is open, but using command netstat -ltn , I see ':::35100'. Looking on the net I understand if in this way is only listen inward and not outward. But I don't understand how can I turn this ':::35100 '-' in this '0.0.0.0:35100 '. Or, better yet, how to add this rule. Any ideas? thanks

    Read the article

  • Socket options for a tcp server with 3G clients & frequent disconnections

    - by Joel
    I have a TCP server, written in java, sending and receiving many short messages, from 500 bytes to 100 KB long. It's a chess game and chat server, to make it simple. The server is running Debian 6. Half of the clients are connecting from 3G networks, and half over standard DSL. A portion of the 3G clients lose connection pretty often. The error I get on the server and on the client socket is Connection reset. I have come across this page at Oracle documentation: socketOpt. I am wondering what I could tune there to lower the number of disconnections from 3G clients. I don't mind about the ping or transfer rate, but just about the TCP disconnections. I am not skilled enough to understand the impact of each setting, but I sort of understood that the TCP window was important, although I don't know exactly how. So I'm asking if anyone here has an idea ? Thanks if you can help.

    Read the article

  • Socket.io v.9 with Actionscript

    - by funseiki
    I'm attempting to develop an online multiplayer game using Node.js for the server and Flash to display the client. I've been reading up a bit and have found quite a few recommendations for the socket.io library. I've also found a github project which exposes code to help facilitate communication between an Actionscript 3.0 client and a server using socket.io. The project I mentioned is a bit dated and doesn't seem to have support for the latest version of socket.io, so I was wondering if leveraging this framework (socket.io, that is) would be the most ideal way to go. I have found a simple project that uses the standard 'net' module for node.js, but because there a few options available, I'm a little lost as to which one to go with. I'm currently leaning towards just using the regular 'net' module as it is already familiar to me. Since much of the client is already coded up, I'd really like to not switch over to using the HTML5 canvas just yet (but using socket.io would make a transition in the future more friendly, I think?). Any advice/direction on this matter would be much appreciated, though I do realize that there may be no one right answer. Edit: To be more specific, are there any client-side socket.io frameworks available that allow for communication between an Actionscript 3.0 client and a socket.io server and are robust enough to support current/future versions of socket.io? If not, what are the alternatives?

    Read the article

  • How can I connect to server using SSL(secure socket layer) on .NET Compact Framework

    - by net
    Hello. I want to change .NET framework v3.5 to .NET compact framework v3.5. But I can't change SSL Stream class to compact framework version. For resolving this problem, I already read some article and msdn library. http://blogs.msdn.com/cgarcia/archive/2009/08/21/enable-ssl-for-managed-socket-on-windows-mobile.aspx http://blogs.msdn.com/cgarcia/archive/2009/08/22/getting-a-managed-socket-to-talk-ssl.aspx http://msdn.microsoft.com/en-us/library/aa916117.aspx but I got an error that is "Unkown error 0x0ffffff", when invoking 'socket.connect(endPoint)' method based on thease article. In order to find the proper method, I try to use TcpClient class. but i can't solve this problem. When I try to connect to server on .NET compact framework, TcpClient class didn't work(Smart Device project and windows ce). As you can see below, I've got the error. In other hand, this code is work on .NET framework(C# console project). I can't understand why this socket can not access to server. Thanks for reading my question.

    Read the article

  • Problem creating socket with C++ in winsock2

    - by Ash85
    Hi, I'm having the weirdest problem causing me headaches. Consider the following code: // Create and bind socket std::map<Connection, bool> clients; unsigned short port=6222; struct sockaddr_in local_address, from_address; int result; char buffer[10000]; SOCKET receive_socket; local_address.sin_family = AF_INET; local_address.sin_addr.s_addr = INADDR_ANY; local_address.sin_port = htons(port); receive_socket = socket(AF_INET,SOCK_DGRAM,0); What's happening is receive_socket is not binding, I get SOCKET_ERROR. When I debug the program and check receive_socket, it appears to just be garbled crap. I put a breakpoint on the 'std::map' line. When I step into each line of the above code, the debug cursor jumps straight from the 'unsigned short port' line to the first 'local_address.sin' line, even though I am using step into (F11), it does not stop at struct, int, char or SOCKET lines, it jumps straight over them. At this point I hover my mouse over local_address, from_address, result, buffer and receive_socket. They are all full of garbled crap. Is this because I have not defined these variables yet? I've also noticed that when I reach the bottom of the above code, local_address.sin_port is set to 19992, but it should be 6222?

    Read the article

  • User input in Perl with IO::Socket

    - by David
    I am trying to make a perl program which allows a user to input the host and the port number of a foreign host to connect to using IO::Socket. It allows me to run the program and input a host and a port but it never connects and says "Could not connect to [host] at c:\users\USER\Documents\code\perl\sql.pl line 18, line 2." What am i doing wrong with this code shown below? And also, how can i have input validation on my host, which can either be a host name or an ip address? Thanks a bunch! Code Below use IO::Socket print "Host to connect to: "; chomp ($host = <STDIN>); print "Port to connect with: "; chomp ($port = <STDIN>); while(($port > 65535) || ($port <= 0)){ print "Port to connect with [Port > 0 < 65535] : "; chomp ($port = <STDIN>); } print "\nConnecting to host $host on port $port\n"; $socket = new IO::Socket::INET ( LocalHost => '$host', LocalPort => '$port', Proto => 'tcp', Listen => 5, Reuse => 1 ); die "Could not connect to $host";

    Read the article

  • Professional Custom Logo Design vs. Mr. Right

    John is an ex-marine and ex-employee of general motors. He recently lost his job working as a welder on the assembly lines of one of GM manufacturing plants. John has traveled a lot and knows a lot a... [Author: Emily Matthew - Web Design and Development - March 31, 2010]

    Read the article

  • Why was Mr. Scott Scottish?

    - by iamjames
    It's a good question:  of all the engineers in the world, why choose a Scottish engineer?  The Gene Roddenberry probably chose a Scottish engineer because of this guy: That's James Watt, the same guy the unit of energy watt is named after.  He was a Scottish inventor and mechancial engineer who built the first made significant improvements to the steam engine.  Made sense in the 60's, however given the past hundred years if they were to make a new Star Trek they might have started with a German engineer (or maybe Japanese), but since World War II had ended barely 20 years earlier the 20-somethings that had survived the war were now 40-somethings and seeing a German engineer probably wouldn't have gone over too well.

    Read the article

  • Getting a UDP socket program in Python to accept messages from a Syslog client?

    - by Elvar
    I'm trying to write a Syslog listener and so far so good on getting it to accept incoming messages through TCP but I also want UDP to function. This is the UDP server code I'm using, which works using a python client app. I also have another app which also works just using the python client app. # Server program # UDP VERSION from socket import * # Set the socket parameters host = "localhost" port = 514 buf = 1024 addr = (host,port) # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(addr) # Receive messages while 1: data,addr = UDPSock.recvfrom(buf) if not data: print "Client has exited!" break else: print "\nReceived message '", data,"'" # Close socket UDPSock.close() Using this code I can send to the server and have it display the code. # Client program from socket import * # Set the socket parameters host = "localhost" port = 514 buf = 1024 addr = (host,port) # Create socket UDPSock = socket(AF_INET,SOCK_DGRAM) def_msg = "===Enter message to send to server==="; print "\n",def_msg # Send messages while (1): data = raw_input('>> ') if not data: break else: if(UDPSock.sendto(data,addr)): print "Sending message '",data,"'....." # Close socket UDPSock.close() I have tried the Kiwi Syslog Message Generator and Snare to send syslog messages to the UDP server and nothing comes up. Could someone help me understand?

    Read the article

  • [java] How to get ALL the information from a socket

    - by raven
    Hello, I'll begin this question with the claim that I have read the java networking guide before asking you. I do not understand how to READ the socket and get all the info summed up into a string. the socket might contains more than 1 line [trying to make a chat]. Please do no refer me to any other site unless it clearly states "this exact line does this.." because I failed to understand what this code part does BufferedReader stdIn = new BufferedReader( new InputStreamReader(System.in)); String userInput; while ((userInput = stdIn.readLine()) != null) { out.println(userInput); System.out.println("echo: " + in.readLine()); } Please, I just want to make a loop that will receive information from a socket, get all the content together into one string [I also want it to know where to add another line]. Thanks allot for anyone who helps, I have been trying to get an answer from tuts for hours and just failed to understand!

    Read the article

  • See socket options on existing sockets created by other apps?

    - by nailer
    I'd like to test whether particular socket options have been set on an existing socket. Ie, pretty much everything you can see in: #!/usr/bin/env python '''See possible TCP socket options''' import socket sockettypelist = [x for x in dir(socket) if x.startswith('SO_')] sockettypelist.sort() for sockettype in sockettypelist: print sockettype Anyone know how I can see the options on existing sockets, ie those created by other processes? Alas nearly all the documentation I read on Python socket programming is about making new sockets.

    Read the article

  • XML Socket and Regular Socket in Flash/Flex does not send message immediately.

    - by kramer
    I am trying to build a basic RIA where my Flex application client opens an XML socket, sends the xml message "people_list" to server, and prints out the response. I have ruby at the server side and I have successfully set up the security policy stuff. The ruby xml server, successfully accepts the connections from Flex, successfully detects when they are closed and can also send messages to client. But; there is a problem... It cannot receive messages from flex client. The messages sent from flex client are queued and sent as one package when the socket is closed. Therefore, the whole wait-for-request-then-reply thing is not working... This is also -kinda- mentioned in the XMLSocket.send() document, where it is stated that the messages are sent async so; they may be delivered at any time in future. But; I need them to be synced, flushed or whatever. This is the server side code: require 'socket' require 'observer' class Network_Reader_Ops include Observable @@reader_listener_socket = UDPSocket.new @@reader_broadcast_socket = UDPSocket.new @@thread_id def initialize @@reader_broadcast_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1) @@reader_broadcast_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1) @@reader_listener_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1) @@reader_broadcast_socket.bind('', 50050) @@reader_listener_socket.bind('', 50051) @@thread_id = Thread.start do loop do begin text, sender = @@reader_listener_socket.recvfrom_nonblock 1024 print("Knock response recived: ", text) notify_observers text rescue Errno::EAGAIN retry rescue Errno::EWOULDBLOCK retry end end end end def query @@reader_broadcast_socket.send("KNOCK KNOCK", 0, "255.255.255.255", 50050) end def stop Thread.kill @@thread_id end end class XMLSocket_Connection attr_accessor :connection_id def update (data) connection_id.write(data+"\0") end end begin # Set EOL for Flash $/ = '\x00' xml_socket = TCPServer.open('', '4444') security_policy_socket = TCPServer.open('', '843') xml_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1) security_policy_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1) a = Thread.start do network_ops = nil loop { accepted_connection = xml_socket.accept print(accepted_connection.peeraddr, " is accepted\n") while accepted_connection.gets incoming = $_.dump print("Received: ", incoming) if incoming == "<request>readers on network</request>" then network_ops = Network_Reader_Ops.new this_con = XMLSocket_Connection.new this_con.connection_id = accepted_connection network_ops.add_observer this_con network_ops.query end end if not network_ops.nil? then network_ops.delete_observer this_con network_ops.stop network_ops = nil end print(accepted_connection, " is gone\n") accepted_connection.close } end b = Thread.start do loop { accepted_connection = security_policy_socket.accept Thread.start do current_connection = accepted_connection while current_connection.gets if $_ =~ /.*policy\-file.*/i then current_connection.write("<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>\0") end end current_connection.close end } end a.join b.join rescue puts "FAILED" retry end And this is the flex/flash client side code: UPDATE: I have also tried using regular socket and calling flush() method but; the result was same. private var socket:XMLSocket = new XMLSocket(); protected function stopXMLSocket():void { socket.close(); } protected function startXMLSocket():void { socket.addEventListener(DataEvent.DATA, dataHandler); socket.connect(xmlSocketServer_address, xmlSocketServer_port); socket.send("<request>readers on network</request>"); } protected function dataHandler(event:DataEvent):void { mx.controls.Alert.show(event.data); } How do I achieve the described behaviour?

    Read the article

  • Java Port Socket Programming Error

    - by atrus-darkstone
    Hi- I have been working on a java client-server program using port sockets. The goal of this program is for the client to take a screenshot of the machine it is running on, break the RGB info of this image down into integers and arrays, then send this info over to the server, where it is reconstructed into a new image file. However, when I run the program I am experiencing the following two bugs: The first number recieved by the server, no matter what its value is according to the client, is always 49. The client only sends(or the server only receives?) the first value, then the program hangs forever. Any ideas as to why this is happening, and what I can do to fix it? The code for both client and server is below. Thanks! CLIENT: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.*; import java.net.Socket; import java.text.SimpleDateFormat; import java.util.*; import javax.swing.*; import javax.swing.Timer; public class ViewerClient implements ActionListener{ private Socket vSocket; private BufferedReader in; private PrintWriter out; private Robot robot; // static BufferedReader orders = null; public ViewerClient() throws Exception{ vSocket = null; in = null; out = null; robot = null; } public void setVSocket(Socket vs) { vSocket = vs; } public void setInput(BufferedReader i) { in = i; } public void setOutput(PrintWriter o) { out = o; } public void setRobot(Robot r) { robot = r; } /*************************************************/ public Socket getVSocket() { return vSocket; } public BufferedReader getInput() { return in; } public PrintWriter getOutput() { return out; } public Robot getRobot() { return robot; } public void run() throws Exception{ int speed = 2500; int pause = 5000; Timer timer = new Timer(speed, this); timer.setInitialDelay(pause); // System.out.println("CLIENT: Set up timer."); try { setVSocket(new Socket("Alex-PC", 4444)); setInput(new BufferedReader(new InputStreamReader(getVSocket().getInputStream()))); setOutput(new PrintWriter(getVSocket().getOutputStream(), true)); setRobot(new Robot()); // System.out.println("CLIENT: Established connection and IO ports."); // timer.start(); captureScreen(nameImage()); }catch(Exception e) { System.err.println(e); } } public void captureScreen(String fileName) throws Exception{ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screenRectangle = new Rectangle(screenSize); BufferedImage image = getRobot().createScreenCapture(screenRectangle); int width = image.getWidth(); int height = image.getHeight(); int[] pixelData = new int[(width * height)]; image.getRGB(0,0, width, height, pixelData, width, height); byte[] imageData = new byte[(width * height)]; String fromServer = null; if((fromServer = getInput().readLine()).equals("READY")) { sendWidth(width); sendHeight(height); sendArrayLength((width * height)); sendImageInfo(fileName); sendImageData(imageData); } /* System.out.println(imageData.length); String fromServer = null; for(int i = 0; i < pixelData.length; i++) { imageData[i] = ((byte)pixelData[i]); } System.out.println("CLIENT: Pixel data successfully converted to byte data."); System.out.println("CLIENT: Waiting for ready message..."); if((fromServer = getInput().readLine()).equals("READY")) { System.out.println("CLIENT: Ready message recieved."); getOutput().println("SENDING ARRAY LENGTH..."); System.out.println("CLIENT: Sending array length..."); System.out.println("CLIENT: " + imageData.length); getOutput().println(imageData.length); System.out.println("CLIENT: Array length sent."); getOutput().println("SENDING IMAGE..."); System.out.println("CLIENT: Sending image data..."); for(int i = 0; i < imageData.length; i++) { getOutput().println(imageData[i]); } System.out.println("CLIENT: Image data sent."); getOutput().println("SENDING IMAGE WIDTH..."); System.out.println("CLIENT: Sending image width..."); getOutput().println(width); System.out.println("CLIENT: Image width sent."); getOutput().println("SENDING IMAGE HEIGHT..."); System.out.println("CLIENT: Sending image height..."); getOutput().println(height); System.out.println("CLIENT: Image height sent..."); getOutput().println("SENDING IMAGE INFO..."); System.out.println("CLIENT: Sending image info..."); getOutput().println(fileName); System.out.println("CLIENT: Image info sent."); getOutput().println("FINISHED."); System.out.println("Image data sent successfully."); } if((fromServer = getInput().readLine()).equals("CLOSE DOWN")) { getOutput().close(); getInput().close(); getVSocket().close(); } */ } public String nameImage() throws Exception { String dateFormat = "yyyy-MM-dd HH-mm-ss"; Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); String fileName = sdf.format(cal.getTime()); return fileName; } public void sendArrayLength(int length) throws Exception { getOutput().println("SENDING ARRAY LENGTH..."); getOutput().println(length); } public void sendWidth(int width) throws Exception { getOutput().println("SENDING IMAGE WIDTH..."); getOutput().println(width); } public void sendHeight(int height) throws Exception { getOutput().println("SENDING IMAGE HEIGHT..."); getOutput().println(height); } public void sendImageData(byte[] imageData) throws Exception { getOutput().println("SENDING IMAGE..."); for(int i = 0; i < imageData.length; i++) { getOutput().println(imageData[i]); } } public void sendImageInfo(String info) throws Exception { getOutput().println("SENDING IMAGE INFO..."); getOutput().println(info); } public void actionPerformed(ActionEvent a){ String message = null; try { if((message = getInput().readLine()).equals("PROCESSING...")) { if((message = getInput().readLine()).equals("IMAGE RECIEVED SUCCESSFULLY.")) { captureScreen(nameImage()); } } }catch(Exception e) { JOptionPane.showMessageDialog(null, "Problem: " + e); } } } SERVER: import java.awt.image.BufferedImage; import java.io.*; import java.net.*; import javax.imageio.ImageIO; /*IMPORTANT TODO: * 1. CLOSE ALL STREAMS AND SOCKETS WITHIN CLIENT AND SERVER! * 2. PLACE MAIN EXEC CODE IN A TIMED WHILE LOOP TO SEND FILE EVERY X SECONDS * */ public class ViewerServer { private ServerSocket vServer; private Socket vClient; private PrintWriter out; private BufferedReader in; private byte[] imageData; private int width; private int height; private String imageInfo; private int[] rgbData; private boolean active; public ViewerServer() throws Exception{ vServer = null; vClient = null; out = null; in = null; imageData = null; width = 0; height = 0; imageInfo = null; rgbData = null; active = true; } public void setVServer(ServerSocket vs) { vServer = vs; } public void setVClient(Socket vc) { vClient = vc; } public void setOutput(PrintWriter o) { out = o; } public void setInput(BufferedReader i) { in = i; } public void setImageData(byte[] imDat) { imageData = imDat; } public void setWidth(int w) { width = w; } public void setHeight(int h) { height = h; } public void setImageInfo(String im) { imageInfo = im; } public void setRGBData(int[] rd) { rgbData = rd; } public void setActive(boolean a) { active = a; } /***********************************************/ public ServerSocket getVServer() { return vServer; } public Socket getVClient() { return vClient; } public PrintWriter getOutput() { return out; } public BufferedReader getInput() { return in; } public byte[] getImageData() { return imageData; } public int getWidth() { return width; } public int getHeight() { return height; } public String getImageInfo() { return imageInfo; } public int[] getRGBData() { return rgbData; } public boolean getActive() { return active; } public void run() throws Exception{ connect(); setActive(true); while(getActive()) { recieve(); } close(); } public void recieve() throws Exception{ String clientStatus = null; int clientData = 0; // System.out.println("SERVER: Sending ready message..."); getOutput().println("READY"); // System.out.println("SERVER: Ready message sent."); if((clientStatus = getInput().readLine()).equals("SENDING IMAGE WIDTH...")) { setWidth(getInput().read()); System.out.println("Width: " + getWidth()); } if((clientStatus = getInput().readLine()).equals("SENDING IMAGE HEIGHT...")) { setHeight(getInput().read()); System.out.println("Height: " + getHeight()); } if((clientStatus = getInput().readLine()).equals("SENDING ARRAY LENGTH...")) { clientData = getInput().read(); setImageData(new byte[clientData]); System.out.println("Array length: " + clientData); } if((clientStatus = getInput().readLine()).equals("SENDING IMAGE INFO...")) { setImageInfo(getInput().readLine()); System.out.println("Image Info: " + getImageInfo()); } if((clientStatus = getInput().readLine()).equals("SENDING IMAGE...")) { for(int i = 0; i < getImageData().length; i++) { getImageData()[i] = ((byte)getInput().read()); } } if((clientStatus = getInput().readLine()).equals("FINISHED.")) { getOutput().println("PROCESSING..."); setRGBData(new int[getImageData().length]); for(int i = 0; i < getRGBData().length; i++) { getRGBData()[i] = getImageData()[i]; } BufferedImage image = null; image.setRGB(0, 0, getWidth(), getHeight(), getRGBData(), getWidth(), getHeight()); ImageIO.write(image, "png", new File(imageInfo + ".png")); //create an image file out of the screenshot getOutput().println("IMAGE RECIEVED SUCCESSFULLY."); } } public void connect() throws Exception { setVServer(new ServerSocket(4444)); //establish server connection // System.out.println("SERVER: Connection established."); setVClient(getVServer().accept()); //accept client connection request // System.out.println("SERVER: Accepted connection request."); setOutput(new PrintWriter(vClient.getOutputStream(), true)); //set up an output channel setInput(new BufferedReader(new InputStreamReader(vClient.getInputStream()))); //set up an input channel // System.out.println("SERVER: Created IO ports."); } public void close() throws Exception { getOutput().close(); getInput().close(); getVClient().close(); getVServer().close(); } }

    Read the article

  • Generic socket 940 CPU fan interchangeable with HP part number 411454-001

    - by ConcernedOfTunbridgeWells
    Hi, I'm trying to find a generic CPU fan that will fit the air duct in an XW9300. Note that there are two CPU fan mounting schemes used on this machine. One with two grommets in the motherboard that the CPU fan screws into and one with a plastic collar and base plate. The form factor I'm looking for is the former (see picture below): Two HP part numbers for fans in this form factor are 411454-001 (shown below) and 416055-001. Note that the dimensions are important as the machine has an air duct that fits over the fan. Can anyone tell me the manufacturer and model of an equivalent generic part? Better yet, do you know somewhere (preferrably in the UK) that I can obtain such an item from?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >