Search Results

Search found 7065 results on 283 pages for 'cpu sockets'.

Page 12/283 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • sending and receiving with sockets in java?

    - by Darksole
    I am working on sending and receiving from clients and servers in java, and am stumped at the moment. the client socket is to contact a server at “localhost” port 4321. The client will receive a string from the server and alternate spelling the contents of this string with the server. For example, given the string “Bye Bye”, the client (which always begins sending the first letter) sends “B”, receives “y”, sends “e”, receives “ ”, sends “B”, receives “y”, sends “e”, and receives “done!”, which is the string that either client or server will send after the last letter from the original string is received. After “done!” is transmitted, both client and server close their communications. How would i go about getting the first string and then going back and forth sending and reciving letters that make the string, and when finished either send or get done!? import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class Program2 { public static void goClient() throws UnknownHostException, IOException{ String server = "localhost"; int port = 4321; Socket socket = new Socket(server, port); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream(); Scanner in = new Scanner(inStream); PrintWriter out = new PrintWriter(outStream, true); String rec = ""; if(in.hasNext()){ rec = in.nextLine(); } char[] array = new char[rec.length()]; for(int i = 0; i < rec.length(); i++){ array[i] = rec.charAt(i); } while(in.hasNext()){ for(int x = 0; x < array.length + 1; x+=2){ String str = in.nextLine(); str = Character.toString(array[x]); out.println(str); } in.close(); socket.close(); } } }

    Read the article

  • How to implement bridging/NAT on linux? [closed]

    - by mikepurvis
    What I have is a network topology which looks like this: ------ PC --- IP Camera The PC has two ethernet interfaces, and is hosting a small webserver providing some auxiliary data. The issue is that the server on the PC runs on port 80, and the IP Camera is also running on port 80. Currently, we are bridging them, so that the PC's server is accessible at 192.168.0.2 and the camera at 192.168.0.3. However, what I'm trying to explore is the feasibility of using the PC to expose them both on the PC's IP, ideally both on port 80. Can this be done with regular sockets, or will it be necessary to use raw sockets?

    Read the article

  • reading partially from sockets

    - by nomad.alien
    I'm having a little test program that sends a lot of udp packets between client-server-client (ping/pong test). The packets are fixed size on each run(last run is max allowable size of udp packet) I'm filling the packets with random data except for the beginning of each packet that contains the packet number. So I'm only interested to see if I receive all the packets back at the client. I'm using sendto() and recvfrom() and I only read the sizeof(packet_number) (which in this case is an int). What happens to the rest of the data? Does it end up in fairyland (gets discarded)? or does the new packet that arrives gets appended to this "old" data? (using linux)

    Read the article

  • Sockets: Transport endpoint is not connected on send

    - by TheoretiCAL
    I'm trying to learn socket programming from http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html and am attempting to build a SOCK_STREAM client/server. My client: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #define SERVERPORT "4951" // the port users will be connecting to int main(int argc, char *argv[]) { int sockfd; struct addrinfo hints, *servinfo, *p; int rv; int numbytes; if (argc != 3) { fprintf(stderr,"usage: talker hostname message\n"); exit(1); } memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if ((rv = getaddrinfo(argv[1], SERVERPORT, &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return 1; } // loop through all the results and make a socket for(p = servinfo; p != NULL; p = p->ai_next) { if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("talker: socket"); continue; if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) { close(sockfd); perror("client: connect"); continue; } } break; } if (p == NULL) { fprintf(stderr, "talker: failed to bind socket\n"); return 2; } if ((numbytes = send(sockfd, argv[2], strlen(argv[2]), 0) == -1)) { perror("talker: send"); exit(1); } freeaddrinfo(servinfo); printf("talker: sent %d bytes to %s\n", numbytes, argv[1]); close(sockfd); return 0; } Server: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #define MYPORT "4951" // the port users will be connecting to #define MAXBUFLEN 100 static int backlog = 10; // get sockaddr, IPv4 or IPv6: void *get_in_addr(struct sockaddr *sa) { if (sa->sa_family == AF_INET) { return &(((struct sockaddr_in*)sa)->sin_addr); } return &(((struct sockaddr_in6*)sa)->sin6_addr); } int main(void) { int sockfd; struct addrinfo hints, *servinfo, *p; int rv; int numbytes; int new_fd; socklen_t addr_size; struct sockaddr_storage their_addr; char buf[MAXBUFLEN]; char s[INET6_ADDRSTRLEN]; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4 hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // use my IP if ((rv = getaddrinfo(NULL, MYPORT, &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return 1; } // loop through all the results and bind to the first we can for(p = servinfo; p != NULL; p = p->ai_next) { if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("listener: socket"); continue; } int yes=1; // lose the pesky "Address already in use" error message if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) { perror("setsockopt"); exit(1); } if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) { close(sockfd); perror("listener: bind"); continue; } if (listen(sockfd,backlog) == -1){ close(sockfd); perror("listener:listen"); continue; } break; } if (p == NULL) { fprintf(stderr, "listener: failed to bind socket\n"); return 2; } freeaddrinfo(servinfo); printf("listener: waiting to recv..\n"); while(1){ addr_size = sizeof their_addr; if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &addr_size))==-1){ perror("accept"); exit(1); } if ((numbytes = recv(new_fd, buf, MAXBUFLEN-1 , 0) == -1)) { perror("recv"); exit(1); } printf("listener: got packet from %s\n", inet_ntop(their_addr.ss_family, get_in_addr((struct sockaddr *)&their_addr), s, sizeof s)); printf("listener: packet is %d bytes long\n", numbytes); buf[numbytes] = '\0'; printf("listener: packet contains \"%s\"\n", buf); close(sockfd); } return 0; } Upon executing the client, I get " send: Transport endpoint is not connected" and I'm not sure where I went wrong. Thanks.

    Read the article

  • Problems with Asynchronous UDP Sockets

    - by ihatenetworkcoding
    Hi, I'm struggling a bit with socket programming (something I'm not at all familiar with) and I can't find anything which helps from google or MSDN (awful). Apologies for the length of this. Basically I have an existing service which recieves and responds to requests over UDP. I can't change this at all. I also have a client within my webapp which dispatches and listens for responses to that service. The existing client I've been given is a singleton which creates a socket and an array of response slots, and then creates a background thread with an infinite looping method that makes "sock.Receive()" calls and pushes the data received into the slot array. All kinds of things about this seem wrong to me and the infinite thread breaks my unit testing so I'm trying to replace this service with one which makes it's it's send/receives asynchronously instead. Point 1: Is this the right approach? I want a non-blocking, scalable, thread-safe service. My first attempt is roughly like this, which sort of worked but the data I got back was always shorter than expected (i.e. the buffer did not have the number of bytes requested) and seemed to throw exceptions when processed. private Socket MyPreConfiguredSocket; public object Query() { //build a request this.MyPreConfiguredSocket.SendTo(MYREQUEST, packet.Length, SocketFlags.Multicast, this._target); IAsyncResult h = this._sock.BeginReceiveFrom(response, 0, BUFFER_SIZE, SocketFlags.None, ref this._target, new AsyncCallback(ARecieve), this._sock); if (!h.AsyncWaitHandle.WaitOne(TIMEOUT)) { throw new Exception("Timed out"); } //process response data (always shortened) } private void ARecieve (IAsyncResult result) { int bytesreceived = (result as Socket).EndReceiveFrom(result, ref this._target); } My second attempt was based on more google trawling and this recursive pattern I frequently saw, but this version always times out! It never gets to ARecieve. public object Query() { //build a request this.MyPreConfiguredSocket.SendTo(MYREQUEST, packet.Length, SocketFlags.Multicast, this._target); State s = new State(this.MyPreConfiguredSocket); this.MyPreConfiguredSocket.BeginReceiveFrom(s.Buffer, 0, BUFFER_SIZE, SocketFlags.None, ref this._target, new AsyncCallback(ARecieve), s); if (!s.Flag.WaitOne(10000)) { throw new Exception("Timed out"); } //always thrown //process response data } private void ARecieve (IAsyncResult result) { //never gets here! State s = (result as State); int bytesreceived = s.Sock.EndReceiveFrom(result, ref this._target); if (bytesreceived > 0) { s.Received += bytesreceived; this._sock.BeginReceiveFrom(s.Buffer, s.Received, BUFFER_SIZE, SocketFlags.None, ref this._target, new AsyncCallback(ARecieve), s); } else { s.Flag.Set(); } } private class State { public State(Socket sock) { this._sock = sock; this._buffer = new byte[BUFFER_SIZE]; this._buffer.Initialize(); } public Socket Sock; public byte[] Buffer; public ManualResetEvent Flag = new ManualResetEvent(false); public int Received = 0; } Point 2: So clearly I'm getting something quite wrong. Point 3: I'm not sure if I'm going about this right. How does the data coming from the remote service even get to the right listening thread? Do I need to create a socket per request? Out of my comfort zone here. Need help.

    Read the article

  • Sending Data as Instances using Python Sockets

    - by Alice
    I'm working on the networking part of a 2 player game (similar to tetris), and I'm trying to pass the game grid from client to server and vice versa. However, when I tried using send(grid) I get a TypeError: send() argument 1 must be string or read-only buffer, not instance. Is there anyway to circumvent this, or do I have to convert my grid instance into a string and then interpret it from the other side? Thanks in advance!

    Read the article

  • How Do Sockets Work in C?

    - by kaybenleroll
    I am a bit confused about socket programming in C. You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article Network programming under Unix systems to be very informative. What confuses me is the timing of data arriving on the socket. How can you tell when packets arrive, and how big the packet is, do you have to do all the heavy lifting yourself? My basic assumption here is that packets can be of variable length, so once binary data starts appearing down the socket, how do you begin to construct packets from that?

    Read the article

  • Current stock price by using sockets in java

    - by user2976396
    My program is to find the current stock price of a symbol ..this is the code which i m using `String yahoo = "finance.yahoo.com" ; final int httpd = 80; Socket sock = new Socket(yahoo,httpd); PrintWriter out = new PrintWriter( sock.getOutputStream(), true ); BufferedReader in =new BufferedReader(new InputStreamReader( sock.getInputStream() ) ); out.println( "GET http://finance.yahoo.com/q?s=ibm&f=1l HTTP/1.0\r\n\r\n " ); out.println(""); out.flush();` I am just getting the output as ibm .Can anyone please suggest how to get the price.

    Read the article

  • Sockets: I/O Error 32

    - by Genesis
    Could someone please explain what an I/O Error 32 refers to in the context of a network socket? I have a multithreaded Socks5 server written using Poco SocketReactors and am getting this error when the server load reaches a certain point. The exception is thrown within my onReadable handlers at the same time across all threads which have connections associated with them. The only other thing I am doing within those threads is std::cout but I am not sure if this is a potential cause.

    Read the article

  • gevent, sockets and syncronisation

    - by schlamar
    I have multiple greenlets sending on a common socket. Is it guaranteed that each package sent via socket.sendall is well separated or do I have to acquire a lock before each call to sendall. So I want to prevent the following scenario: g1 sends ABCD g2 sends 1234 received data is mixed up, for example AB1234CD expected is either ABCD1234 or 1234ABCD Update After a look at the sourcecode I think this scenario cannot happen. But I have to use a lock because g1 or g2 can crash on the sendall. Can someone confirm this?

    Read the article

  • Sending Images over Sockets in C

    - by Takkun
    I'm trying to send an image file through a TCP socket in C, but the image isn't being reassembled correctly on the server side. I was wondering if anyone can point out the mistake? I know that the server is receiving the correct file size and it constructs a file of that size, but it isn't an image file. Client //Get Picture Size printf("Getting Picture Size\n"); FILE *picture; picture = fopen(argv[1], "r"); int size; fseek(picture, 0, SEEK_END); size = ftell(picture); //Send Picture Size printf("Sending Picture Size\n"); write(sock, &size, sizeof(size)); //Send Picture as Byte Array printf("Sending Picture as Byte Array\n"); char send_buffer[size]; while(!feof(picture)) { fread(send_buffer, 1, sizeof(send_buffer), picture); write(sock, send_buffer, sizeof(send_buffer)); bzero(send_buffer, sizeof(send_buffer)); } Server //Read Picture Size printf("Reading Picture Size\n"); int size; read(new_sock, &size, sizeof(1)); //Read Picture Byte Array printf("Reading Picture Byte Array\n"); char p_array[size]; read(new_sock, p_array, size); //Convert it Back into Picture printf("Converting Byte Array to Picture\n"); FILE *image; image = fopen("c1.png", "w"); fwrite(p_array, 1, sizeof(p_array), image); fclose(image);

    Read the article

  • How the clients (client sockets) are identified?

    - by Roman
    To my understanding by serverSocket = new ServerSocket(portNumber) we create an object which potentially can "listen" to the indicated port. By clientSocket = serverSocket.accept() we force the server socket to "listen" to its port and to "accept" a connection from any client which tries to connect to the server through the port associated with the server. When I say "client tries to connect to the server" I mean that client program executes "nameSocket = new Socket(serverIP,serverPort)". If client is trying to connect to the server, the server "accepts" this client (i.e. creates a "client socket" associated with this client). If a new client tries to connect to the server, the server creates another client socket (associated with the new client). But how the server knows if it is a "new" client or an "old" one which has already its socket? Or, in other words, how the clients are identified? By their IP? By their IP and port? By some "signatures"? What happens if an "old" client tries to use Socket(serverIP,serverIP) again? Will server create the second socket associated with this client?

    Read the article

  • Handling large numbers of sockets with .NET

    - by Dreaddan
    I'm looking at writing a application that need to be able to handle in the region of 200 connections / sec and was wondering if C# and .NET will handle this or if I need to really be looking at C++ to do this? It looks like SocketAsyncEventArgs may be the way to go but thought id check before I plough in to it. Each transaction should only last less than a second but could take up to 15 seconds each if that makes any difference.

    Read the article

  • taskmgr.exe 100% CPU Usage

    - by Burnsys
    Hi. I have 2 IBM servers Intel Xeon Dual core with 2gb RAM. the problem is that Taskmanager uses one full core when i open it. The same happens when i copy files in the explorer. OS: Windows 2003 Server Things i tried: Installed all updates They has kaspersky anti virus and they previously had Nod32. All drivers installed OK. All unused devices are disabled in the bios. Reinstalled win 2003 SP2. No conflict in drivers Tried opening via remote desktop and the problem continues. The cpu utilization is in the Kernel Times (Red in taskmanager) If i open Proces Explorer and i navigate to the threads consuming CPU the stack traces ends always in "NtkrnlPA!UnexpectedInterrupt", all threads stacks end in "UnexpectedInterrupt" ntoskrnl.exe!KiUnexpectedInterrupt+0x48 ntoskrnl.exe!KeWaitForMutexObject+0x20e ntoskrnl.exe!CcSetReadAheadGranularity+0x1ff9 ntoskrnl.exe!IoAllocateIrp+0x3fd ntoskrnl.exe!KeWaitForMutexObject+0x20e ntoskrnl.exe!NtWaitForSingleObject+0x94 ntoskrnl.exe!DbgBreakPointWithStatus+0xe05 ntdll.dll!KiFastSystemCallRet kernel32.dll!WaitForSingleObject+0x12 taskmgr.exe+0xeef6 kernel32.dll!GetModuleHandleA+0xdf Any help would be appreciated!

    Read the article

  • CPU installation

    - by David Oneill
    I'm in the midst of building a computer (this is my first time). When I first put the heatsink on the CPU, I was a little off center. Some of the thermal compound came off, so when I re-centered it, it isn't completely evenly distributed. So here's my question: how picky are CPUs in terms of how evenly the thermal compound is? Should I take it apart, clean it, and apply a new layer of compound? Or can I just keep an eye on the CPU temperature? (I'm not overclocking or anything, if that matters)

    Read the article

  • Problems with chip fan and CPU fan

    - by JS Bangs
    I have a five-year-old ASUS motherboard that has been working fine for me for years, until I attempted to power it on yesterday and got a CPU fan speed and chip fan speed warning. Cracking open the case and powering the computer on, I can see the chip fan working, but it appears to be hitting something as it makes a very loud buzzing noise. The CPU fan, meanwhile, starts up when I power on, but slows down and stops after a few seconds! How can I address these problems? Is there any way to fix these sort of fan speed issues without just replacing the fan (which in the case of the chip fan, probably means replacing the whole motherboard)?

    Read the article

  • Limiting Sybase ASE 15 CPU usage on VM

    - by reiniero
    I've set up a single CPU Sybase ASE 15.7 test/hobby/experimentation system on a Debian Squeeze x64 KVM VM. I notice the CPU load goes to 100% and stays there. Definitely not a Sybase guru, only interested to see if some programs I'm running work on the database. Looking at Sybase docs it seems ASE detects the machine is idle and then takes over all processing just waiting for a connection (and if needed, doing some housekeeping apparently). Normally that would be fine but as it is running in a VM it's taking away processor resources other VMs could use - and the increased fan noise of the PC near my desk annoy me. I've tried to remedy this: set the "runnable process search count" parameter from DEFAULT (2000 IRC) to 3 in /opt/sybase/ASE-15_0/SYBASE.cfg from http://sybase.reygrobellet.com/tutorials/install_sybase_vb/standalone04_configure_oralin11#TOC-Configure-kernel I added this to my /etc/init.d/sybase startup script: echo 0 /proc/sys/kernel/randomize_va_space (though I don't think it'll make much difference) How can I tell Sybase to "behave" and not hog the processor - I don't mind reduced performance.

    Read the article

  • Will more memory help my CPU-peaking SQL Server 2008 R2

    - by Tor Haugen
    I'm supporting a system running against a SQL Server 2008 R2. The server is a single-CPU box with 8 GB of memory. As traffic has increased, the server has started saturating, peaking to 100% CPU ever more often. Disk I/O remains moderate (somewhat surprisingly). Obviously, a new server would be the best option. But failing that, can I expect a noticable improvement from installing more RAM? Or does RAM only help for I/O issues (through caching)?

    Read the article

  • CPU fan making noise

    - by superb1
    CPU fan is making noise. I figured out some reasons: Cable coming out of fan is vibrating. And maybe also CPU fan is loose causing vibration. Suggest options. I cleaned the fan. But found that there is no heatsink compound /paste between processor and the fan. Is it OK? My processor is P4 2.4 GHz. Motherboard Intel 845 GVSR.

    Read the article

  • Why is my CPU fan so loud?

    - by tiiquu
    I bought an old PC to use as a second PC. Everything is fine, except for one thing. The CPU fan is terribly loud! I did a lot with PCs but I never did much with CPU fans. If I want to replace it, what do I have to look for? The fan is 8cm long on each side and 11cm diameter. It is just clipped to the cooler. The PC is a P4 3 GHz. I don't want to spend much money, as I only paid 50 euro for the whole PC. I would prefer to buy a fan for 1-3 dollar or something at eBay but I am not quite sure which one I should buy (which fits). Can you advise?

    Read the article

  • CPU Temperature required for auto-shutdown.

    - by ULTRA_POROV
    At what temperature do most motherboards/cpus power down to prevent damage? And what determines this? Is it the bios, the motherboard, the cpu itself? I have a cpu that stays on in the bios until about 105 C and then shuts down. I am not sure if this is correct? Maybe the sensors are wrong. I think 105 is a bit high. I guess 80-90 would be more reasonable for an auto shutdown.

    Read the article

  • Diagnosing high CPU waiting

    - by Will
    I have a monitoring server that is running icinga/collectd/graphite with about 50 hosts. I have noticed high load/slugging performance on the box. If you take a look at top, you'll see: Cpu(s): 0.6%us, 0.2%sy, 0.0%ni, 7.6%id, 23.4%wa, 0.0%hi, 0.2%si, 0.0%st Notice the HUGE %wa value, which as far as I know means a network or disk bottleneck. ifconfig shows no dropping packets and there's not a ton of bandwidth going on, so that leaves disk issues, right? There's not a lot of disk writing going on either...iotop is reporting we're only writing a little over 1 MB per second and the RAID tool reports everything is A-OK and write caching is enabled. How do I go about trying to figure out how to fix this? UPDATE: iostat -x output is: avg-cpu: %user %nice %system %iowait %steal %idle 0.62 0.10 0.31 9.65 0.00 89.31 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda 0.21 33.34 83.55 16.54 1599.94 399.07 19.97 43.21 416.98 3.71 37.13

    Read the article

  • CPU sometimes hangs at 50% maximum on Windows 8

    - by Martin.
    Recently I installed Windows 8 on my HP ProBook 6450b and it appears I've got problems when using more than one program at once. Sometimes, when I run multiple programs at once, CPU hangs at 49% and never goes up. I suspect it has something to do with CPU throttling, because sometimes it just goes over 49%. I've got my notebook connected to charger and my plan is set to "Active cooling". The weird thing is that this happens only occasionally. I found nothing in my BIOS that could change this kind of things.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >