C :: Socket Programming Support Multiple Ports - Defined Variables

Sep 3, 2013

I want to put my socket programming example of how it can support multiple ports. I want to make the process more requests from distributing particles to create non-blocking structure

ports support ports defined variable.

Code:
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "errno.h"
#include "string.h"
#include "sys/socket.h"

[Code] .....

View 2 Replies


ADVERTISEMENT

C :: UDO Socket Programming

Dec 18, 2014

I am trying to test my client-server socket program wherein the client connects to the server,client sends a message, server receives it and echo back to the client.So far, in the program server receives the message from the client, prints it BUT when it tries to send the message back to the client it shows an error.

sendto(): Invalid argument.I am new to socket programming.

Code:

//Server
#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //exit(0)
#include<netinet/in.h>
#include<sys/socket.h>
#define BUFLEN 512 //Max length of buffer
#define PORT 10003 //The port on which to listen for incoming data
}

[code]....

View 3 Replies View Related

C :: Socket Programming Getting Segfault

May 22, 2013

I am trying to send a packet across a client/server communication. I am getting a seg fault (while running the program(It compiles fine)) when I try to read the neighbor file, You should be able to see this below the comment /***** Read neighbor file***/ :

Code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
}

[code]....

View 2 Replies View Related

C :: Socket Programming And Console Control

Jan 4, 2014

I would like to make a program for final project, which can let me send any file to my computer at home, and i can access any files in my computer when i am not at home.sending and getting file will be with socket programming.

i would like to reach all folders in computer, not only the folder, where client program exist. how can i access other folders at remote computer by using my program?

View 4 Replies View Related

C :: Netstat And PS Commands For Client / Server Socket Programming

Mar 3, 2013

I made client server program with fork ,without using signal handler because I want to see the status zombie for parent server, but when i execute "ps" command i didn't see anything for server or client pid or ppid ,i wonder about how to show the server and client process coz when i execute commad "ps" i saw only ps and bash processes???

View 1 Replies View Related

C :: Address Family Not Supported By Protocol In Socket Programming In Linux

Oct 31, 2013

I am writing on C simple socket programs in Linux. I wrote client and server C programs. My client program is Code: #include<sys/socket.h>//for socket(), connect(), sendto() and recvform()

#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#include<stdio.h>// for printf() and fprintf()

[Code]....

I am just testing whether can connect or not. I run server program first and client later. But when I run client, it showed that "Address family not supported by protocol".

View 3 Replies View Related

C/C++ :: TCPIP Socket Client Programming In Redhat Linux Using Eclipse CDT

Mar 16, 2014

This is my sample socket tcp ip program , problem here is when i give working ip address and port number, it is showing default ip address as 127.0.0.1 and it is Waiting on (1978=port number) i.e., "connection on %d...", SERVER_PORT.

void socket_server_demo(void){
int iserver_socket = -1;
int iclient_socket = -1;
unsigned char bTemp[1024];
unsigned int iTemp = 0;

[Code] ....

View 1 Replies View Related

C# :: Using Pre-defined Variables In Process Arguments

Sep 8, 2014

I have struck with issue regarding process arguments

Part of my code below:

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = MsiTran;
[b]info.Arguments = "-a """ + MSTpath + "" " + MSIpath"";[/b]
MSIpath and MSTpath are already defined string variables.

I get error: only assignment call increment decrement .....can be used as statement

How can setup my arguments to cal the pre-defined variables.

View 4 Replies View Related

C :: Linux Socket Multiple Connections But With Different Time Rate

Feb 6, 2015

i want to write a server and a client as below:

The server(and not the clients) will connect to the clients and just send a message. The idea is to be able to connect at each client a different time.

e.g
every 10mins connect at client 1
every 2mins connect at client 2
every 1hour connect at client 3
and so on...

So how to implement this ? Should i create a new child process for each connection and what about the timing ? A pseudo code also will work.

View 4 Replies View Related

C++ :: Are Variables Being Defined As Parameters Separated By Comma

Jan 18, 2013

TinyGPS::TinyGPS()
: _time(GPS_INVALID_TIME)
, _date(GPS_INVALID_DATE)
, _latitude(GPS_INVALID_ANGLE)

[code]....

I am wondering about the constructor. I see there appears to be nothing inside of TinyGPS::TinyGPS() as far as parameters go and that that declaration is followed by a ":". First I'm wondering as to the meaning of the colon. As well with the variables defined after the ":" I see some "(0)" and I am wondering as well to the exact meaning of the "(0)". Are those variables being defined as parameters separated by ","?

View 2 Replies View Related

Visual C++ :: Make Transition From Console Programming To GUI Programming?

Nov 30, 2013

my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore.

View 10 Replies View Related

C :: Adding Constant To Multiple Variables

May 20, 2013

Instead of using:

Code:
x=x+k
y=y+k
z=z+k

Is there a more elegant method of adding the same constant to many variables?

Something like: Code: (x, y, z) = (x, y, z) + k ??

View 5 Replies View Related

C++ :: Global Variables For Multiple CPP Files

Jan 19, 2014

I am trying to get variables that are global to multiple files. I have mananged to make constant variables that are global but maybe not in the best way. In the header i have the constant variables being defined:

const int variable_Name = 5;

And the cpp file:

#include <iostream>
using namespace std;
#include "vars.h"
int main ( ) {
cout << variable_Name<< endl;
system ("pause");
return 0;
}

Is there a better way to do this and to make the variables able to be changed within the cpp files.

View 7 Replies View Related

C++ :: Bit-checking Across Multiple Classes Private Variables

Oct 6, 2013

I am writing a bit-check function just to make it easier on myself to check status flags in my classes. I use char variables and each bit represents something on or off. Since I have numerous classes that will use this functionality, it makes sense to write and compile the code only one time rather than for each class. I was thinking of writing the function and including it as a "friend" function to each class that needs it. Is that an appropriate way to do it?

View 2 Replies View Related

C++ :: Returning Multiple Variables In 1 Function To Main

Oct 22, 2013

I am trying to return 2 numbers from my function to main(). They are both read in from an input file but it is not working out.

#include <fstream>
#include <iostream>
using namespace std;
ofstream outfile;
void heading(int);
int stuid(int,int);

[Code] ....

View 4 Replies View Related

C/C++ :: How To Create A Table With Variables From Multiple Structs

Aug 1, 2012

I would like to create an array of struct variables inside a table to avoid using many if/else and/or switch/case statements. I have attached a simple example of what I am trying to do, it doesn't work. For the table "sTablePtr" I see different values than what I set, when I dereference it with a "&" it just shows me the addresses of the variables. However at the end, when I do print out the values, by just using the structs themselves, they print out the values correctly.

My structure declarations must remain a pointer. To be clear, what I am trying to do is have sTablePtr[i] show me the correct values I set, in this case I want the for loop to print out 1, 2 and 3. If there is a different way of doing this, I am open to it as long as I can use a table of my struct variables to avoid many if statements.

#define MAX_CNT 3  
typedef struct {
   int nNum;
   int nCnt;   
}sDummy1;  

[Code] ....

View 4 Replies View Related

C :: Read From And Store Values Of Each Line In Multiple Variables

May 6, 2013

So I have this text file that I am trying to read from and store the values of each line in multiple variables. Let's say my text file contains

AXSYZ3482 Tom 100 112 and my code below here works fine when the lines in the text file is separated by spaces.

Code:

while (fscanf(fp, "%s %s %d %d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

But let's say my file was to look like this instead.

AXSYZ3482:Tom:100:112

But if i try this below...

Code:

while (fscanf(fp, "%s:%s:%d:%d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

It seem to store the entire line in userID including the ":". I want to ignore the ":"'s and store everything in between in respective varibles in the order specified above.

So first string in userID, then ignore the :, then second string in name, and ignore the next :, and so forth.

View 4 Replies View Related

C++ :: Reading From File And Store Values Of Each Line In Multiple Variables

May 6, 2013

So I have this text file that I am trying to read from and store the values of each line in multiple variables.

Let's say my text file contains

AXSYZ3482 Tom 100 112

and my code below here works fine when the lines in the text file is separated by spaces.

while (fscanf(fp, "%s %s %d %d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

But let's say my file was to look like this instead.

AXSYZ3482:Tom:100:112

But if i try this below...

while (fscanf(fp, "%s:%s:%d:%d
", userID, name, &startLoc, &endLoc) != EOF) {
printf("%s %s %d %d
", userID, name, startLoc, endLoc);
}

It seem to store the entire line in userID including the ":". I want to ignore the ":"'s and store everything in between in respective varibles in the order specified above.

So first string in userID, then ignore the :, then second string in name, and ignore the next :, and so forth. How I can accomplish this?

View 2 Replies View Related

C++ :: Control Usb Ports?

Mar 5, 2013

how to control usb ports in visual studio C++?

View 1 Replies View Related

C :: Using COM Ports To Send Files Between Two PCs

Dec 2, 2014

My first time programming sth in Network. I have to use C to send a file to another PC, well COM port are useful but I didn't find how to refer to the address of my destination.

View 4 Replies View Related

C++ :: Get Input From Ports And Send Output

Jul 30, 2014

I'm learning C++. Is there some way to make program function on input from a port like usb port and can I send bits through the port? For example A usb cable connected to a circuit. I press a button and an AND gate on the circuit gets activated by a bit from the usb port and a fan in the room turns on.

View 1 Replies View Related

C# :: Reading Byte From Serial Ports

Jun 8, 2014

how to use this function:

ftStatus = myFtdiDevice.Read(readData, numBytesAvailable,ref numBytesRead);

to read byte from the serial port.This function is part of the DLL that came with the chip(FT2232D) I am using on my board.I want to use the function to read a byte from the serial port and then send the value to the Graphic user interface.Unfortunately I was unable to get the expected value on my GUI.If I send for instance 40,what I get on the GUI are letters instead of the number 40 or at times the GUI will not even respond.Below are my lines of code I used to read the byte from the serial port:

The following instructions are executed whenever the CHECKBOX is checked

private
void checkBox1_CheckedChanged(object sender, EventArgs e)
{
UInt32 numBytesRead = 0;

[Code].....

View 3 Replies View Related

C++ :: Detecting TR1 Support?

Feb 3, 2012

I have source code that is shared between two compilers, one supports TR1 and one doesn't. I've reverse engineered a few of the TR1 templates for the older compiler, but I need to be able to detect whether TR1 is supported or not, so as to include the correct header.

Something like this.

Code:
#ifdef SUPPORTS_TR1
#include <array>
#else
#include "mystl/array"
#endif
std::array<int, 10> myarray;

The compiler that supports TR1 is Visual Studio.

View 2 Replies View Related

C :: Selection Menu With Enter Key Support

Apr 27, 2013

I am working on a database project, which can store (initially) 10,000 marksheets with following capabilities

1) new entry
2) edit/modification of entry
3)delete entry
4) separate Departements ( BBA, BCS, M.Phil, Phd., etc.)
5) can store data on files ( initially, all data is stored in a single file)

Now, I want to create a menu, in which i can use arrow keys to navigate through the menu and use Enter key fo selection.

What should i use in it?? The project is only on C language.

View 4 Replies View Related

C++ :: Unicode Support For Windows Renaming API?

Nov 7, 2013

I had a file which has name like SIRAO.wav Since this file name has special unicode character all file API's are failed.

I would like to rename this file using Windows API. How can achieve this?

std::string filename variable hold this value as SIRÃO.wav.

I try to read the file using file API after perform a conversion.

Code:
const int utf16_length = MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),NULL,0);
std::wstring utf16;
utf16.resize(utf16_length);
MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),&utf16[0],utf16.length());
const wchar_t *name = utf16.c_str();

rename the file with unicode character?

View 3 Replies View Related

Visual C++ :: Use CFormView As Main View Without Using Document Support?

Jul 17, 2013

Is it possible to use a CFormView as the main view without using document support. IE pointing CWinApps m_pMainWnd to the CFrameWnd derived MainFrame and attaching the CFormView from there. It does not seem to be working and I was wondering before I waste any more time on the solution if it is even possible. I know it is an easy solution if I create a true SDI application however I have no use for documents in this application.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved