|
I don't see, if sockets.h is a platform/SDK header. Try commenting that header, whether error you would get for functions; are application specific or somethig else.
|
|
|
|
|
i tried to find the file using Windows Search but i coudn't find it. It there another library i could use for socket programming.
|
|
|
|
|
so is this what you've beeing trying to do? You have lovely API for thatWinSock Search CP for "Winsock". You'll need to scroll for pages.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
As I said, it could be other applicatin specific header. Try commenting it out.
Mridang Agarwal wrote: It there another library i could use for socket programming.
If you are using MFC , you can go with Socket classes.
Otherwise use winsock[^].
|
|
|
|
|
i tried commenting it out but it then the program doent run because all the the socket functions dont work.
|
|
|
|
|
Can you name the functions that are giving errors?
|
|
|
|
|
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include "helper.h"
#include <stdlib.h>
#include <stdio.h>
#define ECHO_PORT (2002)
#define MAX_LINE (1000)
int main(int argc, char *argv[]) {
int list_s;
int conn_s;
short int port;
struct sockaddr_in servaddr;
char buffer[MAX_LINE];
char *endptr;
if ( argc == 2 ) {
port = strtol(argv[1], &endptr, 0);
if ( *endptr ) {
fprintf(stderr, "ECHOSERV: Invalid port number.\n");
exit(EXIT_FAILURE);
}
}
else if ( argc < 2 ) {
port = ECHO_PORT;
}
else {
fprintf(stderr, "ECHOSERV: Invalid arguments.\n");
exit(EXIT_FAILURE);
}
if ( (list_s = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
fprintf(stderr, "ECHOSERV: Error creating listening socket.\n");
exit(EXIT_FAILURE);
}
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(port);
if ( bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) {
fprintf(stderr, "ECHOSERV: Error calling bind()\n");
exit(EXIT_FAILURE);
}
if ( listen(list_s, LISTENQ) < 0 ) {
fprintf(stderr, "ECHOSERV: Error calling listen()\n");
exit(EXIT_FAILURE);
}
while ( 1 ) {
if ( (conn_s = accept(list_s, NULL, NULL) ) < 0 ) {
fprintf(stderr, "ECHOSERV: Error calling accept()\n");
exit(EXIT_FAILURE);
}
Readline(conn_s, buffer, MAX_LINE-1);
Writeline(conn_s, buffer, strlen(buffer));
if ( close(conn_s) < 0 ) {
fprintf(stderr, "ECHOSERV: Error calling close()\n");
exit(EXIT_FAILURE);
}
}
}
this is the code. there is one more file called "helper.h". this file contaisn cote for the readline and write functions. nothing important.
|
|
|
|
|
Mridang Agarwal wrote: #include <sys socket.h=""> /* socket definitions */#include <sys types.h=""> /* socket types */#include <arpa inet.h="">
Hey this is for UNIX!!
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
BTW, why did you say SOCKETS.h????? .. You really wasted many's time. When you ask something please see to that you are asking with the correct details.If you had mentioned the right word, we could have helped you faster. Good Luck nextime.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
i am really sorry guys. A messed up and all because of a small tpyo. Won't happen again. Thanks for all the help.
|
|
|
|
|
It's ok dude.. No problem
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Did you find this file?
|
|
|
|
|
I am using this code to save data in txt file but i just dont understand what went wrong in that it saves all data rather then that market detail only.
<br />
<br />
CString csMarket="EURUSD";<br />
CString usMarket ="USDJPY";<br />
CString gbMarket="GBPUSD" ;<br />
<br />
if(csMarket == Market)
{<br />
myfile.Open("EurUsd.txt",CFile.modeCreate | CFile.modeWrite);<br />
<br />
LPSTR buf;<br />
int i= m_MainEdit.GetLength();<br />
buf = m_MainEdit.GetBuffer(i);<br />
myfile.Write(buf,i);<br />
myfile.Close();<br />
<br />
}<br />
else if(strcmp( Market,"USDJPY") == 0) <br />
<br />
{<br />
myfile.Open("UsdJpy.txt",CFile.modeCreate | CFile.modeWrite);<br />
LPSTR buf1;<br />
int i = m_MainEdit.GetLength();<br />
buf1 = m_MainEdit.GetBuffer(i);<br />
myfile.Write(buf1,i);<br />
myfile.Close();<br />
}<br />
<br />
else if(gbMarket == Market)<br />
{<br />
myfile.Open("GbpUsd.txt",CFile.modeCreate | CFile.modeWrite);<br />
<br />
LPSTR buf2;<br />
int i = m_MainEdit.GetLength();<br />
buf2 = m_MainEdit.GetBuffer(i);<br />
myfile.Write(buf2,i);<br />
myfile.Close();<br />
<br />
}<br />
|
|
|
|
|
Show the definition of Market . Wont thing's be more easier if you store your Market in a CString csMarket ?
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Market is the name of market like2 "usdjpy","gld","slv" etc and with this, rate of market and the days highest "bid" and the lowest "bid"
|
|
|
|
|
Try this,
<br />
CString Market;<br />
<br />
if(Market==usMarket)<br />
{<br />
}<br />
else if(Market==csMarket)<br />
{<br />
<br />
}<br />
else if(Market==gbMarket)<br />
{<br />
<br />
}<br />
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
I cant do thsi caz Market detail are coming from remote server i need to save only this 3 market detail in txt file
CString csMarket="EURUSD";
CString usMarket ="USDJPY";
CString gbMarket="GBPUSD" ;
|
|
|
|
|
You'll get any one of these at a time ? if so, you can do one thing :
From your code, Market looks like a char* so you would better do,
<br />
myfile.Open(Market,CFile.modeCreate | CFile.modeWrite);<br />
So that it writes into separate files according to the value of "Market".
Or I still dont get your problem?
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
abrakadbra wrote: if(csMarket == Market) //,myfile.Open("EurUsd.txt",CFile.modeCreate | CFile.modeWrite)
{
myfile.Open("EurUsd.txt",CFile.modeCreate | CFile.modeWrite);
// myfile.Write((LPCTSTR)m_MainEdit,m_MainEdit.GetLength()*sizeof(TCHAR));
LPSTR buf;
int i= m_MainEdit.GetLength();
buf = m_MainEdit.GetBuffer(i);
myfile.Write(buf,i);
myfile.Close();
}
Is this the snippet of code that you are questioning?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes do you have any idea how to correct the following code....how to store only one market data in one txt file.
|
|
|
|
|
abrakadbra wrote: yes do you have any idea how to correct the following code....how to store only one market data in one txt file.
Like has been said at least two times before, change buf to only contain the data you wanted saved to the file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Is there any source code or link for databse programming which tell us how to save data in datbase coming from remote server.
|
|
|
|
|
|
abrakadbra wrote: Is there any source code or link for databse programming which tell us how to save data in datbase coming from remote server.
try msdn samples! or google
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|
|
Exception Handeling seems to hide behind obsure procedures. I've read and understood the principles as set out in Matt Pietrecks various articles on the subject, somehow, VCPP5.00 appears to work differently.
All I want to do is throw an exception, as a DWORD value of my liking, so that a catch block can either deal with it true a switch statement, or throw it further down the chain by default. It occurs to me that that's sort of basic, which even VCPP5.00 should be able to handle.
LateNightsInNewry
|
|
|
|