Jump to content
  • Advertisement

Sagar_Indurkhya

Member
  • Content Count

    1312
  • Joined

  • Last visited

Community Reputation

253 Neutral

About Sagar_Indurkhya

  • Rank
    Contributor
  1. I'm trying to write two programs, a C program and a Scheme program that can talk to each other using sockets. The Scheme program acts as the server, and the C program as the client. I can get it to work if the Scheme program acts as the client and the C program as the server, but not the other way around. Is there anything obvious I'm missing? The C Client program: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <iostream> using namespace std; #define SERVER_IP "127.0.0.1" #define ADDR_LEN (sizeof(struct sockaddr)) #define PORT 20000 extern int errno; int main() { int fd_client; struct sockaddr_in serv_addr; char buf[256]; int check_ret; buf[0] = '\0'; fd_client = socket(AF_INET, SOCK_STREAM, 0); if(fd_client < 0) { printf("error creating socket. errno is %d\n", errno); exit(1); } serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(PORT); serv_addr.sin_addr.s_addr = inet_addr(SERVER_IP); bzero(&(serv_addr.sin_zero), 8); check_ret = connect(fd_client, (struct sockaddr *) &serv_addr, ADDR_LEN); if(check_ret < 0) { printf("Connect error. Errno is %d\n", errno); exit(1); } cout << "Entering read loop..." << std::endl; while(1) { printf("READ : "); read(fd_client, buf, 256); printf("%s", buf); bzero(buf, 256); } return 0; } and the scheme server program: (define mySS (open-tcp-server-socket 20000)) (define myPort (tcp-server-connection-accept mySS #t #f)) (write-char #\z myPort) (flush-output myPort) ; stuff should appear on the client side now!
  2. Sagar_Indurkhya

    politics and gamedev

    At one point my rating dropped below 128. Now it's back over 1000! Perhaps I hold the record for biggest change in rating?
  3. Sagar_Indurkhya

    An interesting math problem...

    I think it's probably easier to solve the problem in base 2, and then show somehow that a solution in base 2 maps to the existence of a solution in base 10.
  4. Sagar_Indurkhya

    This Simple Problem Deserves A Simple Answer!!!

    You want to take 3 probability density functions that are identical and combine them to get a new PDF that has the same form. The normal distribution does just this; if you add several normal dist's, you get another normal dist. For x1, x2, and x3, do the following: for x1, let CDF(y1) = x1, and solve for y1. Now you have y1, y2, and y3, three normally distributed numbers. Then let CDF(z) = y1 + y2 + Y3. z is your random number. There will be some linear scaling of the inputs required, and the new normal PDF that is generated must be normalized, but the basic idea is correct. Now as for solving the inverse CDF equation, I'm sure you can find something on the internet or just use a reverse lookup table.
  5. Sagar_Indurkhya

    Olives

    Mmmm Olives. After reading this thread, I decided I had to taste some olives (which I hadn't tasted in a long time) and immediately walked to the store and bought a jar. Pimiento-stuffed green olives and some bread is what I'm having now. That is all.
  6. Sagar_Indurkhya

    Why do we enjoy coding?

    ``I think that it's extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customers got shafted every now and then, and after a while we began to take their complaints seriously. We began to feel as if we really, were responsible for the successful, error-free perfect use of these machines. I don't think we are. I think we're responsible for stretching them, setting them off in new directions, and keeping fun in the house. I hope the field of computer science never loses its sense of fun. Above all, I hope we don't become missionaries. Don't feel as if you're Bible salesmen. The world has too many of those already. What you know about computing other people will learn. Don't feel as if the key to successful computing is only in your hands. What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more.'' - Alan Perlis, Foreword for Structure and Interpretation of Computer Programs.
  7. Sagar_Indurkhya

    Nerd Sniping

    Quote:Original post by Talroth Been awhile since I studied that branch of physics (aka, high school, 6 years ago maybe?) but isn't that an impossible circuit anyway? The solution to computing the theoretical effective resistance of this circuit requires mathematical machinery well beyond that taught in traditional high schools (which I'm assuming ends at single variable calculus). EDIT: although yes, I do think high school students should be able to recognize this circuit is impossible to build exactly. :) But I think you can get a reasonable approximation of it with today's fabrication techniques.
  8. Sagar_Indurkhya

    Something to chew on for the math savy

    I believe you can obtain the solution by just taking the laplace transform of the 2nd order homogenous equation, and then working the algebra and doing the inverse transform. I should know how to do this, so I'll brush up on my Laplace Transforms later today. Here is what I have so far: y'' + y'/x - k^2*y = 0 Now take the laplace transform: [s^2*X(s) - s*X(0) - X'(0)] + [integral(X'(z) dz, s, infinity)] - k^2*X(s) = 0 Now solve for X(s). Then do the inverse laplace transform! Note that you will have constants emerging for the y(0) and the y'(0).
  9. I'm in the process of practicing for a competition by writing several complicated algorithms in java. Part of the goal is to minimize the total number of bytecode instructions that the JVM executes (and each round I'm allowed to use up to a limit between 1,000 and 10,000 bytecodes). My main focus is on writing the algorithms cleverly, but since at some points in my application I'm looping, I figure that even small unnecessary things will eat up lots of bytecodes if I'm not weary. Also it intrigues me. :) One thing I have kept in mind is that even if my algorithm when compiled into java bytecode might take up 50,000 bytecode instructions, but if a lot of it is branching etc, then I can still get away with not executing most of them. Any tips and pointers? I've never really thought about optimizing at bytecode level in Java (since the emphasis in Java seems to be that you DON"T want to be doing this level of optimization, but it's the nature of competition).
  10. Sagar_Indurkhya

    Reading the signal from a phone line

    I'm trying to read the raw signal from a phone line via a C/C++ or Python library. I was wondering if anyone has run into anything like this?
  11. Sagar_Indurkhya

    DIY project with old printer

    I've recently acquired an old printer that was going to be thrown out but I saved it and want to do some kind of interesting project with it. It's USB interfaced Epson Stylus Photo R200. I googled around for DIY type projects but couldn't find much for printers... does anyone have any ideas? I thought the fact that it can move the ink cartridge printer part very very precisely is something I would like to take advantage of (otherwise I would have just stripped it for spare motors, etc).
  12. I'm trying to design digital circuits for base n, n >= 2. Suppose n = 5. Then I have a vector of inputs, x = <x0, x1, x2>, each of which can be 0, 1, 2, 3 or 4. For a given input vector, I have an output vector y = <y0, y1, y2>, each of which can be 0, 1, 2, 3 or 4. For some input vectors, the output is "Don't Care" as in it doesn't matter what the output is. What I want to do is derive an optimized circuit built from logic gates. These *logic gates* should operate in base n (5 in this case), so I don't want to simply decompose everything into our traditional boolean logic gates. (and I want to automate this process so a computer program can do this). I've been looking around. I got some books on boolean algebra, and studied karnaugh maps, but those don't seem to tend themselves towards automation. I've started trying to decipher the Espresso heuristic logic minimizer, but I was wondering if anyone knew of any other methods. A last note, this work is for purely theoretical purposes, and is actually intended for studying chemical computing.
  13. I am currently searching for a good random number generator for use with C/C++. Specifically, I need to generate uniform and normal distributions. This is for a scientific simulation application. I know that the standard rand() function apparently doesn't make the cut as being random enough, so what are some good alternatives? So far I've found this one: http://oldmill.uchicago.edu/~wilder/Code/random/
  14. Store a global CURRENT_RETURN_CODE; In each function, right at the end, set the value of the global CURRENT_RETURN_CODE to whatever you want. Then after you call a function, just check the value of the global variable! Sure it's not a great OOP approach. But You could probably turn that into some type of static return code class or something. As long as you check the return code from a function call before calling any other functions (who would then overwrite the CURRENT_RETURN_CODE), this should work for any possible setup (excluding multi-threaded coded which I do not know much about).
  15. Sagar_Indurkhya

    Ubuntu is driving me deaf!

    Volume's not muted. Yeah I tried alsactl. At this point I'm too frustrated. My university gives out Red Hat Enterprise for free on campus. I really liked how everything was very easy in Ubuntu to configure /install, etc, so I was wondering if Red Hat Linux Enterprise would be a step in the gentoo direction too much?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!