Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to develop my own application to connect with NSE through .net. for this I got a IP address,User Id and password from NSE. Now I know That .net can Interact IP protocol. Now How can I connect to NSE Sites to get Live quotes(Feed) via UDP. I want to develop my application in .net. What will be the Procedure? Is there any need of extra hardware? any protocol?
Can anybody give me Idea How can I connect with that Server and receive feed?
Give me any Idea. it's very urgent.
Posted
Updated 19-Oct-16 21:40pm
Comments
Goutam Patra 4-Dec-10 7:31am    
See my edited answer.

/*
 * File:   main.c
 * Author: root
 *
 * Created on May 17, 2011, 1:51 PM
 */
<pre>*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#include "lzo/lzo1z.h"
#include "struct.h"


#define MAX_LEN 1024;

int main(int argc, char **argv)
{

int sock;
int flag_on = 1;
struct sockaddr_in mc_addr;
unsigned char recv_str[1024];
int recv_len;
struct ip_mreq mc_req;
char* mc_addr_str;
unsigned short mc_port;
struct sockaddr_in from_addr;
unsigned int from_len;
mc_addr_str = "233.1.1.11";
mc_port = 34330;

if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
perror("socket() failed");
exit(1);
}

if ((setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag_on, sizeof(flag_on))) < 0)
{
perror("setsockopt() failed");
exit(1);
}

memset(&mc_addr,0,sizeof(mc_addr));
mc_addr.sin_family = AF_INET;
mc_addr.sin_addr.s_addr = htonl(INADDR_ANY);
mc_addr.sin_port = htons(mc_port);

if((bind(sock,(struct sockaddr *) &mc_addr,sizeof(mc_addr))) < 0)
{
perror("bind() failed");
exit(1);
}

mc_req.imr_multiaddr.s_addr = inet_addr(mc_addr_str);
mc_req.imr_interface.s_addr = htonl(INADDR_ANY);

if((setsockopt(sock,IPPROTO_IP,IP_ADD_MEMBERSHIP,(void*) &mc_req,sizeof(mc_req))) < 0)
{
perror("setsockopt() failed");
exit(1);
}


for(;;)
{
memset(recv_str,0,sizeof(recv_str));
from_len = sizeof(from_addr);
memset(&from_addr,0,from_len);

if((recv_len = recvfrom(sock, recv_str,1024,0,(struct sockaddr*)&mc_addr, &from_len))<0)
{
perror("recvfrom() failed");
exit(1);
}
short compLen=0;
short NOP=0;
memcpy(&compLen,recv_str+4,2);
compLen = ntohs(compLen);
if(compLen > 0)
{
memcpy(&NOP,recv_str+2,2);
NOP=ntohs(NOP);
int i=0;


for(i=0;i<nop;i++)>
{
unsigned char src[compLen];
memcpy(&src,recv_str+6,compLen);
short src_len = compLen;
unsigned int dst_len = 1024;
unsigned char dst[1024];
int rCode;
unsigned int eCode=0;


rCode = lzo1z_decompress((lzo_bytep) src,(lzo_uint)src_len,(lzo_bytep) dst,(lzo_uintp)&dst_len,0);


}
}
}

if((setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP,(void*)&mc_req, sizeof(mc_req))) < 0)
{
perror("setsocketopt() failed");
exit(1);

}
close(sock);
return 0;
}
 
Share this answer
 
v2
Comments
mehulgoti 9-May-18 5:57am    
plz can you help me in this regards
Mehul Goti - Contact No : 9409165073
I dont think anybody will help you in this regard. I can only give you some clue.
If you want to connect to NSE broadcast server then just join the multicast group (Google for how to) you will start receiving packets. After that you have to decode (refer to documents provided by NSE for how to ) those packets to get Live quotes.


[EDIT]
See, I cannot give you whole solution. I just gave you some clue. So that you can at least start with.
[END EDIT]
 
Share this answer
 
v2
Comments
Raghvendra Kumar Roy 4-Dec-10 4:00am    
Thanks for this. Now I have an IP . when Now I am Connected with this server.
But I am unable to receive any packet. Can u tell me is there any need of Hardware or protocol? Will I have to send user Id and password in specific struture ?
Raghvendra Kumar Roy 7-Dec-10 2:07am    
Dear

I am making my own application to receive packet from NSE sever and i am success in it. But my problem is all the packets is in byte format. now how can I get LIVE quotes of any company(scrips)to decode these packets. When I store these bytes in text file it looks like :

 YZ**123 @

How can I get Live feed from this . If anybody know pls help me?

Thanks and regards
Raghvendra kumar Roy
sandiplakhani 2-Jun-12 1:07am    
hi, did you receive live feed from NSE ?
sandiplakhani 2-Jun-12 1:08am    
then kindly let me know how can we receive.
sandipp.lakhani@gmail.com
avm222 1-Jul-11 8:41am    
hi Raghvendra,
using udp socket then endpoint, then join multicast group, port, then bind i did
all these but nse data not coming where as when i change multicast group address and port to listen my sender app listner app getting data. pls help me to get broadcast data from nse.
regards,
abhirup
Hi Raghvendra Kumar Roy,

Can you provide me the IP / code you have done till now?. May be I could help you.

vikas_361 @ hotmail.com
Vikas
 
Share this answer
 
Comments
Virender_samer 21-Nov-11 9:03am    
Hi Vikas,

As I am having the same problem like Raghvendra could you please help me out I am sending you the code on your mail ID "vikas_361 @ hotmail.com" please revert me back as soon as possible.

my mail ID is: v i r u 1 2 8 4 @ g m a i l . c o m
Member 8977787 18-Oct-13 6:30am    
Please share the code
Virender_samer 29-Jun-12 2:50am    
got it, I have sorted out the problem.
neo100894 22-Apr-23 5:38am    
hi Virender,
I'm facing similar issue, can I know how you fixed this issue?
Dear Raghvendra Kumar,

From nse You need to purchase different type of feeds , feed you can get in udp/tcp server , you can get rate feed from tcp/udp format , you will get it in byte format , when you get response same response available in LZO compress mode you can decompress in lzo format . then you can get it heder details and footer data in

In header you get
Data compresss or not , size of data packer and total record.

in details records.

Prakash Vala
Sr Software Engineer
9033019822
 
Share this answer
 
Comments
Southmountain 21-Oct-16 12:38pm    
could you let me know how to purchase these data feeds?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900