Search Results

Search found 361 results on 15 pages for 'fin'.

Page 5/15 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How Hacker Can Access VPS CentOS 6 content?

    - by user2118559
    Just want to understand. Please, correct mistakes and write advices Hacker can access to VPS: 1. Through (using) console terminal, for example, using PuTTY. To access, hacker need to know port number, username and password. Port number hacker can know scanning open ports and try to login. The only way to login as I understand need to know username and password. To block (make more difficult) port scanning, need to use iptables configure /etc/sysconfig/iptables. I followed this https://www.digitalocean.com/community/articles/how-to-setup-a-basic-ip-tables-configuration-on-centos-6 tutorial and got *nat :PREROUTING ACCEPT [87:4524] :POSTROUTING ACCEPT [77:4713] :OUTPUT ACCEPT [77:4713] COMMIT *mangle :PREROUTING ACCEPT [2358:200388] :INPUT ACCEPT [2358:200388] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [2638:477779] :POSTROUTING ACCEPT [2638:477779] COMMIT *filter :INPUT DROP [1:40] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [339:56132] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP -A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -s 11.111.11.111/32 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT -A INPUT -s 11.111.11.111/32 -p tcp -m tcp --dport 21 -j ACCEPT COMMIT Regarding ports that need to be opened. If does not use ssl, then seems must leave open port 80 for website. Then for ssh (default 22) and for ftp (default 21). And set ip address, from which can connect. So if hacker uses other ip address, he can not access even knowing username and password? Regarding emails not sure. If I send email, using Gmail (Send mail as: (Use Gmail to send from your other email addresses)), then port 25 not necessary. For incoming emails at dynadot.com I use Email Forwarding. Does it mean that emails “does not arrive to VPS” (before arriving to VPS, emails are forwarded, for example to Gmail)? If emails does not arrive to VPS, then seems port 110 also not necessary. If use only ssl, must open port 443 and close port 80. Do not understand regarding port 3306 In PuTTY with /bin/netstat -lnp see Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 992/mysqld As understand it is for mysql. But does not remember that I have opened such port (may be when installed mysql, the port is opened automatically?). Mysql is installed on the same server, where all other content. Need to understand regarding port 3306 2. Also hacker may be able access console terminal through VPS hosting provider Control Panel (serial console emergency access). As understand only using console terminal (PuTTY, etc.) can make “global” changes (changes that can not modify with ftp). 3. Hacker can access to my VPS exploiting some hole in my php code and uploading, for example, Trojan. Unfortunately, faced situation that VPS was hacked. As understand it was because I used ZPanel. On VPS ( \etc\zpanel\panel\bin) ) found one php file, that was identified as Trojan by some virus scanners (at virustotal.com). Experimented with the file on local computer (wamp). And appears that hacker can see all content of VPS, rename, delete, upload etc. From my opinion, if in PuTTY use command like chattr +i /etc/php.ini then hacker could not be able to modify php.ini. Is there any other way to get into VPS?

    Read the article

  • Random pauses with "Key dispatching timed out sending to <null>" when closing Android SurfaceView

    - by kenyee
    When I close an Android SurfaceView Activity, the app sometimes pauses and almost gets an ANR (Application Not Responding) message. Looking at LogCat, it appears to be timing out trying to send keys to it. I tried modifying the code to setFocusable(false) when in the onKeyDown handler for the SurfaceView, but that doesn't seem to affect this. Any other ideas on what might be causing this? Or what these messages in Logcat even mean? ============================= 05-31 19:35:35.285: INFO/WindowManager(586): focus null mToken is null at event dispatch! 05-31 19:35:35.295: WARN/WindowManager(586): Current state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to null @ 1275334535292 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=null}} 05-31 19:35:35.305: WARN/WindowManager(586): Continuing to wait for key to be dispatched 05-31 19:35:40.306: WARN/WindowManager(586): Key dispatching timed out sending to 05-31 19:35:40.316: WARN/WindowManager(586): Dispatch state: {{KeyEvent{action=0 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to Window{43763540 com.myapp/com.myapp.DiagramEdit paused=false} @ 1275334499512 lw=Window{43763540 com.myapp/com.myapp.DiagramEdit paused=false} lb=android.os.BinderProxy@43702190 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=null}} 05-31 19:35:40.326: INFO/WindowManager(586): focus null mToken is null at event dispatch! 05-31 19:35:40.326: WARN/WindowManager(586): Current state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to null @ 1275334540327 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=null}} 05-31 19:35:40.326: WARN/WindowManager(586): Continuing to wait for key to be dispatched

    Read the article

  • search data from FileReader in Java

    - by maya
    hi I'm new in java how to read and search data from file (txt) and then display the data in TextArea or Jtable. for example I have file txt contains data and I need to display this data in textarea after I clicked a button, I have used FileReader , and t1 t2 tp are attributes in the file import java.io.FileReader; import java.io.IOException; String t1,t2,tp; Ffile f1= new Ffile(); FileReader fin = new FileReader("test2.txt"); Scanner src = new Scanner(fin); while (src.hasNext()) { t1 = src.next(); textarea.setText(t1); t2 = src.next(); textarea.setText(t2); tp = src.next(); textarea.setText(tp); f1.insert(t1,t2,tp); } fin.close(); also I have used the inputstream DataInputStream dis = null; String dbRecord = null; try { File f = new File("text2.text"); FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); dis = new DataInputStream while ( (dbRecord = dis.readLine()) != null) { StringTokenizer st = new StringTokenizer(dbRecord, ":"); String t1 = st.nextToken(); String t2 = st.nextToken(); String tp = st.nextToken(); textarea.setText(textarea.getText()+t1); textarea.setText(textarea.getText()+t2); textarea.setText(textarea.getText()+tp); } } catch (IOException e) { // catch io errors from FileInputStream or readLine() System.out.println("Uh oh, got an IOException error: " + e.getMessage()); } finally { } but both of them don't work ,so please any one help me I want to know how to read data and also search it from file and i need to display the data in textarea . thanks in advance

    Read the article

  • Java FileLock for Reading and Writing

    - by bobtheowl2
    I have a process that will be called rather frequently from cron to read a file that has certain move related commands in it. My process needs to read and write to this data file - and keep it locked to prevent other processes from touching it during this time. A completely separate process can be executed by a user to (potential) write/append to this same data file. I want these two processes to play nice and only access the file one at a time. The nio FileLock seemed to be what I needed (short of writing my own semaphore type files), but I'm having trouble locking it for reading. I can lock and write just fine, but when attempting to create lock when reading I get a NonWritableChannelException. Is it even possible to lock a file for reading? Seems like a RandomAccessFile is closer to what I need, but I don't see how to implement that. Here is the code that fails: FileInputStream fin = new FileInputStream(f); FileLock fl = fin.getChannel().tryLock(); if(fl != null) { System.out.println("Locked File"); BufferedReader in = new BufferedReader(new InputStreamReader(fin)); System.out.println(in.readLine()); ... The exception is thrown on the FileLock line. java.nio.channels.NonWritableChannelException at sun.nio.ch.FileChannelImpl.tryLock(Unknown Source) at java.nio.channels.FileChannel.tryLock(Unknown Source) at Mover.run(Mover.java:74) at java.lang.Thread.run(Unknown Source) Looking at the JavaDocs, it says Unchecked exception thrown when an attempt is made to write to a channel that was not originally opened for writing. But I don't necessarily need to write to it. When I try creating a FileOutpuStream, etc. for writing purposes it is happy until I try to open a FileInputStream on the same file.

    Read the article

  • Is it possible to make a persistent connection between a Python web service and a .Net WCF Client?

    - by Ad Hock
    I have a .Net 3.5 SOAP client written in C# using the WCF. It's expecting basicHTTPBinding and a persistent connection with HTTP/1.1. I'm trying to create a Python 2.6 application that will act as a web-service for the client. My problem is that the client keeps closing the connection and opening a new one for every command to the web service. How does the .Net WCF client know to stay open when connecting with a .Net Service? When I create a dummy .Net web service the client connects fine and the connection remains persistent. From what I can tell, when connected to a .Net server, there are no special HTTP headers being sent, that makes sense since HTTP/1.1 assumes a persistent connection unless otherwise specified (right?). However, with the python web service I accept/open a connection and eventually the client will send a TCP FIN and the connection will close (the client never sends a FIN or RST when connecting to a .Net service). The communication goes something like this: Incoming -- HTTP Header for SOAP Command #1 Outgoing -- HTTP Header with a Continue Incoming -- Body of Command #1 Outgoing -- ACK Command #1 (HTTP headers and body) Incoming -- HTTP Header for SOAP Command #2 Outgoing -- HTTP Header with a Continue Incoming -- TCP FIN <Connection closes> <New connection opens and SOAP command #2 (with full HTTP headers) is sent> I'm using a SocketServer.ThreadingTCPServer as the server and a BaseHTTPServer.BaseHTTPRequestHandler for any requests. The handler is actually a derived class of that with a do_POST method to handle the HTTP headers. I've looked at WireShark captures and I'm stumped. I've tried setting socket options to SO_KEEPALIVE and SO_REUSEADDR in the server but that didn't seem to change anything. What am I missing?

    Read the article

  • Read from file hexadecimal number and change their representation style

    - by user576844
    I want to write a program changing the notation of all hexadecimal numbers found in an assembly source file from traditional (h) to C-style (0x). I have started the coding part but am not sure how can I detect the hexadecimal numbers and eventually change the style and save it back in the file... I have started writing the program.. ## Mips program - .data fin: .ascii "" # filename for input msg0: .asciiz "aaaa" msg1: .asciiz "Please enter the input file name:" buffer: .asciiz "" .text #----------------------- li $v0, 4 la $a0, msg1 syscall li $v0, 8 la $a0, fin li $a1, 21 syscall jal fileRead #read from file move $s1, $v0 #$t0 = total number of bytes li $t0, 0 # Loop counter loop: bge $t0, $s1, end #if end of file reached OR if there is an error in the file lb $t5, buffer($t0) #load next byte from file jal checkhexa #check for hexadecimal numbers addi $t0, $t0, 1 #increment loop counter j loop end: jal output jal fileClose li $v0, 10 syscall fileRead: # Open file for reading li $v0, 13 # system call for open file la $a0, fin # input file name li $a1, 0 # flag for reading li $a2, 0 # mode is ignored syscall # open a file move $s0, $v0 # save the file descriptor # reading from file just opened li $v0, 14 # system call for reading from file move $a0, $s0 # file descriptor la $a1, buffer # address of buffer from which to read li $a2, 100000 # hardcoded buffer length syscall # read from file jr $ra Any help would be appreciated.

    Read the article

  • NSTableView don't display data

    - by Tomas Svoboda
    HI, I have data in NSMutableArray and I want to display it in NSTableView, but only the number of cols has changed. This use of NSTableView is based on tutorial: http://www.youtube.com/watch?v=5teN5pMf-rs FinalImageBrowser is IBOutlet to NSTableView @implementation AppController NSMutableArray *listData; - (void)awakeFromNib { [FinalImageBrowser setDataSource:self]; } - (IBAction)StartReconstruction:(id)sender { NSMutableArray *ArrayOfFinals = [[NSMutableArray alloc] init]; //Array of list with final images NSString *FinalPicture; NSString *PicNum; int FromLine = [TextFieldFrom intValue]; //read number of start line int ToLine = [TextFieldTo intValue]; //read number of finish line int RecLine; for (RecLine = FromLine; RecLine < ToLine; RecLine++) //reconstruct from line to line { Start(RecLine); //start reconstruction //Create path of final image FinalPicture = @"FIN/final"; PicNum = [NSString stringWithFormat: @"%d", RecLine]; FinalPicture = [FinalPicture stringByAppendingString:PicNum]; FinalPicture = [FinalPicture stringByAppendingString:@".bmp"]; [ArrayOfFinals addObject:FinalPicture]; // add path to array } listData = [[NSMutableArray alloc] init]; [listData autorelease]; [listData addObjectsFromArray:ArrayOfFinals]; [FinalImageBrowser reloadData]; NSBeep(); //make some noise NSImage *fin = [[NSImage alloc] initWithContentsOfFile:FinalPicture]; [FinalImage setImage:fin]; } - (int)numberOfRowsInTableView:(NSTableView *)tv { return [listData count]; } - (id)tableView:(NSTableView *)tv objectValueFromTableColumn:(NSTableColumn *)tableColumn row:(int)row { return (NSString *)[listData objectAtIndex:row]; } @end when the StartReconstruction end the number of cols have changed right, but they're empty. When I debug app, items in listData is rigth. Thanks

    Read the article

  • Line End Problem Reading with Scanner Class in Java

    - by dikbas
    I am not an experienced Java programmer and i'm trying to write some text to a file and then read it with Scanner. I know there are lots of ways of doing this, but i want to write records to file with delimiters, then read the pieces. The problem is so small. When I look the output some printing isn't seen(shown in below). I mean the bold line in the Output that is only written "Scanner". I would be appreciated if anyone can answer why "String: " isn't seen there. (Please answer just what i ask) I couldn't understand if it is a simple printing problem or a line end problem with "\r\n". Here is the code and output: import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class Tmp { public static void main(String args[]) throws IOException { int i; boolean b; String str; FileWriter fout = new FileWriter("test.txt"); fout.write("Testing|10|true|two|false\r\n"); fout.write("Scanner|12|one|true|"); fout.close(); FileReader fin = new FileReader("Test.txt"); Scanner src = new Scanner(fin).useDelimiter("[|\\*]"); while (src.hasNext()) { if (src.hasNextInt()) { i = src.nextInt(); System.out.println("int: " + i); } else if (src.hasNextBoolean()) { b = src.nextBoolean(); System.out.println("boolean: " + b); } else { str = src.next(); System.out.println("String: " + str); } } fin.close(); } } Here is the output: String: Testing int: 10 boolean: true String: two String: false Scanner int: 12 String: one boolean: true

    Read the article

  • Tomcat 6 HTTPS connector: keep alive timeout not being respected

    - by sehugg
    I'm using Tomcat 6.0.24 on Ubuntu (JDK 1.6) with an app that does Comet-style requests on an HTTPS connector (directly against Tomcat, not using APR). I'd like to set the keep-alive to 5 minutes so I don't have to refresh my long-polling connections. Here is my config: <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="1000" keepAliveTimeout="330000" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> Unfortunately it seems that the server closes the connection after 65 seconds. The pcap from a sample session goes something like this: T=0 Client sends SYN to server, handshake etc. T=65 Server sends FIN to client T=307 Client sends FIN to server (I'm guessing the 5 minute timeout on the client is due to the HTTP lib not detecting the socket close on the server end, but in any case -- the server shouldn't be closing the connection that early) (edit: this works as expected when using the standard HTTP connector)

    Read the article

  • wait after call command minecraft

    - by smeagogol
    I'm trying to create a batch file for a friend because he has some problems on minecraft. He needs to launch minecraft 80 times without closing java error... I have 2 batches, one with a while, and an other one executing java command for launching minecraft. ::Launcher.bat title Script Minecraft set tour=10 set tour2=tour :boucle set /a tour=tour-1 call "D:\thepath\Minecraft2.bat" if %tour%==0 goto suite goto boucle :suite wait javaw.exe :boucle2 set /a tour2=tour2-1 taskkill /F /IM "javaw.exe" if %tour2%==0 goto fin goto boucle2 :fin echo Appuyez sur une touche pour quitter... pause >nul and the other one ::Minecraft2.bat @echo off java -Xmx2048m -Xms1024m -cp "D:\thepath\Minecraft.exe" net.minecraft.LauncherFrame My problem is that when it calls the second batch, it's waiting for closure of the window but we must leave them opened ! If someone has already encountered this problem, I'd be grateful. Thanks PS: If my english is bad, it's because I'm french ;)

    Read the article

  • reading the file name from user input in MIPS assembly

    - by Hassan Al-Jeshi
    I'm writing a MIPS assembly code that will ask the user for the file name and it will produce some statistics about the content of the file. However, when I hard code the file name into a variable from the beginning it works just fine, but when I ask the user to input the file name it does not work. after some debugging, I have discovered that the program adds 0x00 char and 0x0a char (check asciitable.com) at the end of user input in the memory and that's why it does not open the file based on the user input. anyone has any idea about how to get rid of those extra chars, or how to open the file after getting its name from the user?? here is my complete code (it is working fine except for the file name from user thing, and anybody is free to use it for any purpose he/she wants to): .data fin: .ascii "" # filename for input msg0: .asciiz "aaaa" msg1: .asciiz "Please enter the input file name:" msg2: .asciiz "Number of Uppercase Char: " msg3: .asciiz "Number of Lowercase Char: " msg4: .asciiz "Number of Decimal Char: " msg5: .asciiz "Number of Words: " nline: .asciiz "\n" buffer: .asciiz "" .text #----------------------- li $v0, 4 la $a0, msg1 syscall li $v0, 8 la $a0, fin li $a1, 21 syscall jal fileRead #read from file move $s1, $v0 #$t0 = total number of bytes li $t0, 0 # Loop counter li $t1, 0 # Uppercase counter li $t2, 0 # Lowercase counter li $t3, 0 # Decimal counter li $t4, 0 # Words counter loop: bge $t0, $s1, end #if end of file reached OR if there is an error in the file lb $t5, buffer($t0) #load next byte from file jal checkUpper #check for upper case jal checkLower #check for lower case jal checkDecimal #check for decimal jal checkWord #check for words addi $t0, $t0, 1 #increment loop counter j loop end: jal output jal fileClose li $v0, 10 syscall fileRead: # Open file for reading li $v0, 13 # system call for open file la $a0, fin # input file name li $a1, 0 # flag for reading li $a2, 0 # mode is ignored syscall # open a file move $s0, $v0 # save the file descriptor # reading from file just opened li $v0, 14 # system call for reading from file move $a0, $s0 # file descriptor la $a1, buffer # address of buffer from which to read li $a2, 100000 # hardcoded buffer length syscall # read from file jr $ra output: li $v0, 4 la $a0, msg2 syscall li $v0, 1 move $a0, $t1 syscall li $v0, 4 la $a0, nline syscall li $v0, 4 la $a0, msg3 syscall li $v0, 1 move $a0, $t2 syscall li $v0, 4 la $a0, nline syscall li $v0, 4 la $a0, msg4 syscall li $v0, 1 move $a0, $t3 syscall li $v0, 4 la $a0, nline syscall li $v0, 4 la $a0, msg5 syscall addi $t4, $t4, 1 li $v0, 1 move $a0, $t4 syscall jr $ra checkUpper: blt $t5, 0x41, L1 #branch if less than 'A' bgt $t5, 0x5a, L1 #branch if greater than 'Z' addi $t1, $t1, 1 #increment Uppercase counter L1: jr $ra checkLower: blt $t5, 0x61, L2 #branch if less than 'a' bgt $t5, 0x7a, L2 #branch if greater than 'z' addi $t2, $t2, 1 #increment Lowercase counter L2: jr $ra checkDecimal: blt $t5, 0x30, L3 #branch if less than '0' bgt $t5, 0x39, L3 #branch if greater than '9' addi $t3, $t3, 1 #increment Decimal counter L3: jr $ra checkWord: bne $t5, 0x20, L4 #branch if 'space' addi $t4, $t4, 1 #increment words counter L4: jr $ra fileClose: # Close the file li $v0, 16 # system call for close file move $a0, $s0 # file descriptor to close syscall # close file jr $ra Note: I'm using MARS Simulator, if that makes any different

    Read the article

  • One row is skipped each time the program scans a matrix from file !

    - by ZaZu
    Hello there, I had this code working yesterday, but it seems like I edited it a bit and lost the working version. I cant get this to work anymore. I basically want to scan a matrix from a .txt file. But each time it scans the first row, the second one is skipped, and it reads the third instead :( Here is my code : for(i=0;i<=test->rowmat1;i++){ for(j=0;j<=test->colmat1;j++){ fscanf(fin,"%f\t",&test->mat[i][j]); } fscanf(fin,"%*[^\n]",&test->mat[i][j]); } For example, for a matrix of : 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 If I extract 3 rows and 3 cols, I get : 1.00 2.00 3.00 7.00 8.00 9.00 Then fails, it wants to skip over the second line but there is nothing after 10 11 12 Why did it stop working ? What do I have wrong ? Please help, Thanks in advance.

    Read the article

  • Does writing data to server using Java URL class require response from server?

    - by gigadot
    I am trying to upload files using Java URL class and I have found a previous question on stack-overflow which explains very well about the details, so I try to follow it. And below is my code adopted from the sniplet given in the answer. My problem is that if I don't make a call to one of connection.getResponseCode() or connection.getInputStream() or connection.getResponseMessage() or anything which is related to reponse from the server, the request will never be sent to server. Why do I need to do this? Or is there any way to write the data without getting the response? P.S. I have developed a server-side uploading servlet which accepts multipart/form-data and save it to files using FileUpload. It is stable and definitely working without any problem so this is not where my problem is generated. import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; import org.apache.commons.io.IOUtils; public class URLUploader { public static void closeQuietly(Closeable... objs) { for (Closeable closeable : objs) { IOUtils.closeQuietly(closeable); } } public static void main(String[] args) throws IOException { File textFile = new File("D:\\file.zip"); String boundary = Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value. HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:8080/upslet/upload").openConnection(); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); OutputStream output = output = connection.getOutputStream(); PrintWriter writer = writer = new PrintWriter(output, true); // Send text file. writer.println("--" + boundary); writer.println("Content-Disposition: form-data; name=\"file1\"; filename=\"" + textFile.getName() + "\""); writer.println("Content-Type: application/octet-stream"); FileInputStream fin = new FileInputStream(textFile); writer.println(); IOUtils.copy(fin, output); writer.println(); // End of multipart/form-data. writer.println("--" + boundary + "--"); output.flush(); closeQuietly(fin, writer, output); // Above request will never be sent if .getInputStream() or .getResponseCode() or .getResponseMessage() does not get called. connection.getResponseCode(); } }

    Read the article

  • nested iterator errors

    - by Sean
    //arrayList.h #include<iostream> #include<sstream> #include<string> #include<algorithm> #include<iterator> using namespace std; template<class T> class arrayList{ public: // constructor, copy constructor and destructor arrayList(int initialCapacity = 10); arrayList(const arrayList<T>&); ~arrayList() { delete[] element; } // ADT methods bool empty() const { return listSize == 0; } int size() const { return listSize; } T& get(int theIndex) const; int indexOf(const T& theElement) const; void erase(int theIndex); void insert(int theIndex, const T& theElement); void output(ostream& out) const; // additional method int capacity() const { return arrayLength; } void reverse(); // new defined // iterators to start and end of list class iterator; class seamlessPointer; seamlessPointer begin() { return seamlessPointer(element); } seamlessPointer end() { return seamlessPointer(element + listSize); } // iterator for arrayList class iterator { public: // typedefs required by C++ for a bidirectional iterator typedef bidirectional_iterator_tag iterator_category; typedef T value_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef T& reference; // constructor iterator(T* thePosition = 0) { position = thePosition; } // dereferencing operators T& operator*() const { return *position; } T* operator->() const { return position; } // increment iterator& operator++() // preincrement { ++position; return *this; } iterator operator++(int) // postincrement { iterator old = *this; ++position; return old; } // decrement iterator& operator--() // predecrement { --position; return *this; } iterator operator--(int) // postdecrement { iterator old = *this; --position; return old; } // equality testing bool operator!=(const iterator right) const { return position != right.position; } bool operator==(const iterator right) const { return position == right.position; } protected: T* position; }; // end of iterator class class seamlessPointer: public arrayList<T>::iterator { // constructor seamlessPointer(T *thePosition) { iterator::position = thePosition; } //arithmetic operators seamlessPointer & operator+(int n) { arrayList<T>::iterator::position += n; return *this; } seamlessPointer & operator+=(int n) { arrayList<T>::iterator::position += n; return *this; } seamlessPointer & operator-(int n) { arrayList<T>::iterator::position -= n; return *this; } seamlessPointer & operator-=(int n) { arrayList<T>::iterator::position -= n; return *this; } T& operator[](int n) { return arrayList<T>::iterator::position[n]; } bool operator<(seamlessPointer &rhs) { if(int(arrayList<T>::iterator::position - rhs.position) < 0) return true; return false; } bool operator<=(seamlessPointer & rhs) { if (int(arrayList<T>::iterator::position - rhs.position) <= 0) return true; return false; } bool operator >(seamlessPointer & rhs) { if (int(arrayList<T>::iterator::position - rhs.position) > 0) return true; return false; } bool operator >=(seamlessPointer &rhs) { if (int(arrayList<T>::iterator::position - rhs.position) >= 0) return true; return false; } }; protected: // additional members of arrayList void checkIndex(int theIndex) const; // throw illegalIndex if theIndex invalid T* element; // 1D array to hold list elements int arrayLength; // capacity of the 1D array int listSize; // number of elements in list }; #endif //main.cpp #include<iostream> #include"arrayList.h" #include<fstream> #include<algorithm> #include<string> using namespace std; bool compare_nocase (string first, string second) { unsigned int i=0; while ( (i<first.length()) && (i<second.length()) ) { if (tolower(first[i])<tolower(second[i])) return true; else if (tolower(first[i])>tolower(second[i])) return false; ++i; } if (first.length()<second.length()) return true; else return false; } int main() { ifstream fin; ofstream fout; string str; arrayList<string> dict; fin.open("dictionary"); if (!fin.good()) { cout << "Unable to open file" << endl; return 1; } int k=0; while(getline(fin,str)) { dict.insert(k,str); // cout<<dict.get(k)<<endl; k++; } //sort the array sort(dict.begin, dict.end(),compare_nocase); fout.open("sortedDictionary"); if (!fout.good()) { cout << "Cannot create file" << endl; return 1; } dict.output(fout); fin.close(); return 0; } Two errors are: ..\src\test.cpp: In function 'int main()': ..\src\test.cpp:50:44: error: no matching function for call to 'sort(<unresolved overloaded function type>, arrayList<std::basic_string<char> >::seamlessPointer, bool (&)(std::string, std::string))' ..\src\/arrayList.h: In member function 'arrayList<T>::seamlessPointer arrayList<T>::end() [with T = std::basic_string<char>]': ..\src\test.cpp:50:28: instantiated from here ..\src\/arrayList.h:114:3: error: 'arrayList<T>::seamlessPointer::seamlessPointer(T*) [with T = std::basic_string<char>]' is private ..\src\/arrayList.h:49:44: error: within this context Why do I get these errors? Update I add public: in the seamlessPointer class and change begin to begin() Then I got the following errors: ..\hw3prob2.cpp:50:46: instantiated from here c:\wascana\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/stl_algo.h:5250:4: error: no match for 'operator-' in '__last - __first' ..\/arrayList.h:129:21: note: candidate is: arrayList<T>::seamlessPointer& arrayList<T>::seamlessPointer::operator-(int) [with T = std::basic_string<char>, arrayList<T>::seamlessPointer = arrayList<std::basic_string<char> >::seamlessPointer] c:\wascana\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/stl_algo.h:5252:4: instantiated from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = arrayList<std::basic_string<char> >::seamlessPointer, _Compare = bool (*)(std::basic_string<char>, std::basic_string<char>)]' ..\hw3prob2.cpp:50:46: instantiated from here c:\wascana\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/stl_algo.h:2190:7: error: no match for 'operator-' in '__last - __first' ..\/arrayList.h:129:21: note: candidate is: arrayList<T>::seamlessPointer& arrayList<T>::seamlessPointer::operator-(int) [with T = std::basic_string<char>, arrayList<T>::seamlessPointer = arrayList<std::basic_string<char> >::seamlessPointer] Then I add operator -() in the seamlessPointer class ptrdiff_t operator -(seamlessPointer &rhs) { return (arrayList<T>::iterator::position - rhs.position); } Then I compile successfully. But when I run it, I found memeory can not read error. I debug and step into and found the error happens in stl function template<typename _RandomAccessIterator, typename _Distance, typename _Tp, typename _Compare> void __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance __len, _Tp __value, _Compare __comp) { const _Distance __topIndex = __holeIndex; _Distance __secondChild = __holeIndex; while (__secondChild < (__len - 1) / 2) { __secondChild = 2 * (__secondChild + 1); if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) __secondChild--; *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild)); ////// stop here __holeIndex = __secondChild; } Of course, there must be something wrong with the customized operators of iterator. Does anyone know the possible reason? Thank you.

    Read the article

  • How to work with file and streams in php,case: if we open file in Class A and pass open stream to Cl

    - by Rachel
    I have two class, one is Business Logic Class{BLO} and the other one is Data Access Class{DAO} and I have dependency in my BLO class to my Dao class. Basically am opening a csv file to write into it in my BLO class using inside its constructor as I am creating an object of BLO and passing in file from command prompt: Code: $this->fin = fopen($file,'w+') or die('Cannot open file'); Now inside BLO I have one function notifiy, which call has dependency to DAO class and call getCurrentDBSnapshot function from the Dao and passes the open stream so that data gets populated into the stream. Code: Blo Class Constructor: public function __construct($file) { //Open Unica File for parsing. $this->fin = fopen($file,'w+') or die('Cannot open file'); // Initialize the Repository DAO. $this->dao = new Dao('REPO'); } Blo Class method that interacts with Dao Method and call getCurrentDBSnapshot. public function notifiy() { $data = $this->fin; var_dump($data); //resource(9) of type (stream) $outputFile=$this->dao->getCurrentDBSnapshot($data); // So basically am passing in $data which is resource((9) of type (stream) } Dao function: getCurrentDBSnapshot which get current state of Database table. public function getCurrentDBSnapshot($data) { $query = "SELECT * FROM myTable"; //Basically just preparing the query. $stmt = $this->connection->prepare($query); // Execute the statement $stmt->execute(); $header = array(); while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) { if(empty($header)) { // Get the header values from table(columnnames) $header = array_keys($row); // Populate csv file with header information from the mytable fputcsv($data, $header); } // Export every row to a file fputcsv($data, $row); } var_dump($data);//resource(9) of type (stream) return $data; } So basically in am getting back resource(9) of type (stream) from getCurrentDBSnapshot and am storing that stream into $outputFile in Blo class method notify. Now I want to close the file which I opened for writing and so it should be fclose of $outputFile or $data, because in both the cases it gives me: var_dump(fclose($outputFile)) as bool(false) var_dump(fclose($data)) as bool(false) and var_dump($outputFile) as resource(9) of type (Unknown) var_dump($data) as resource(9) of type (Unknown) My question is that if I open file using fopen in class A and if I call class B method from Class A method and pass an open stream, in our case $data, than Class B would perform some work and return back and open stream and so How can I close that open stream in Class A's method or it is ok to keep that stream open and not use fclose ? Would appreciate inputs as am not very sure as how this can be implemented.

    Read the article

  • Building a webserver, client doesn't acknowledge HTTP 200 OK frame.

    - by Evert
    Hi there, I'm building my own webserver based on a tutorial. I have found a simple way to initiate a TCP connection and send one segment of http data (the webserver will run on a microcontroller, so it will be very small) Anyway, the following is the sequence I need to go through: receive SYN send SYN,ACK receive ACK (the connection is now established) receive ACK with HTTP GET command send ACK send FIN,ACK with HTTP data (e.g 200 OK) receive FIN,ACK <- I don't recieve this packet! send ACK Everything works fine until I send my acknowledgement and HTTP 200 OK message. The client won't send an acknowledgement to those two packages and thus no webpage is being displayed. I've added a pcap file of the sequence how I recorded it with wireshark. Pcap file: http://cl.ly/5f5 (now it's the right data) All sequence and acknowledgement numbers are correct, checksum are ok. Flags are also right. I have no idea what is going wrong.

    Read the article

  • Tcp Socket Closed

    - by Michael Covelli
    I always thought that if you didn't implement a heartbeat, there was no way to know if one side of a TCP connection died unexpectedly. If the process was just killed on one side and didn't exit gracefully, there was no way for the socket to send FIN or let the other side know that it was closed. (See some of the comments here for example http://www.perlmonks.org/?node_id=566568 ) But there is a stock order server that I connect to that has a new "cancel all orders on disconnect feature" that cancels live orders if the client dis-connects. It works even when I kill the process on my end, and there is definitely no heartbeat from my app to it. So how is it able to detect when I've killed the process? My app is running on Windows Server 2003 and the order server is on Suse Linux Enterprise Server 10. Does Windows detect that the process associated with the socket is no longer alive and send the FIN?

    Read the article

  • How to sum up values of an array in assembly?

    - by Pablo Fallas
    I have been trying to create a program which can sum up all the values of an "array" in assembly, I have done the following: ORG 1000H TABLE DB DUP(2,4,6,8,10,12,14,16,18,20) FIN DB ? TOTAL DB ? MAX DB 13 ORG 2000H MOV AL, 0 MOV CL, OFFSET FIN-OFFSET TABLE MOV BX, OFFSET TABLE LOOP: ADD AL, [BX] INC BX DEC CL JNZ LOOP HLT END BTW I am using msx88 to compile this code. But I get an error saying that the code 0 has not been recognized. Any advise?

    Read the article

  • Accessing Password Protected Network Drives in Windows in C#?

    - by tkeE2036
    Hi Everyone, So in C# I am trying to access a file on a network, for example at "//applications/myapp/test.txt", as follows: const string fileLocation = @"//applications/myapp/test.txt"; using (StreamReader fin = new StreamReader(FileLocation)) { while(!fin.EndOfStream()){ //Do some cool stuff with file } } However I get the following error: System.IO.IOException : Logon failure: unknown user name or bad password. I figure its because I need to supply some network credentials but I'm not sure how to get those to work in this situation. Does anyone know the best way (or any way) to gain access to these files that are on a a password protected location? Thanks in advance!!

    Read the article

  • How do I read from a file consists of city names and coordinates/Populations and create functions to get the coordinates and population?

    - by Braybray
    I'm using Python, and I have a file which has city names and information such as names, coordinates of the city and population of the city: Youngstown, OH[4110,8065]115436 Yankton, SD[4288,9739]12011 966 Yakima, WA[4660,12051]49826 1513 2410 Worcester, MA[4227,7180]161799 2964 1520 604 Wisconsin Dells, WI[4363,8977]2521 1149 1817 481 595 How can I create a function to take the city name and return a list containing the latitude and longitude of the given city? fin = open ("miles.dat","r") def getCoordinates cities = [] for line in fin: cities.append(line.rstrip()) for word in line: print line.split() That's what I tried now; how could I get the coordinates of the city by calling the names of the city and how can I return the word of each line but not letters? Any help will be much appreciated, thanks all.

    Read the article

  • como puedo hacer funcionar el subwoofer sonicmaster en mi asus n46vb ubuntu 12.04?

    - by Leonidas Franco Carranza Oliva
    soy nuevo en ubuntu y me compre hace poco el asus n46vb con ubuntu 12.04 y que viene con un subwoofer sonicmaster, pero parece que no esta configurado en el sistema y no lo reconoce cuando lo conecto, estuve leyendo y probé con esto No sound from external subwoofer "Sonic Master" on an Asus N76VM pero no me sirvió ya que hay un archivo que no existe y creo que debe ser por el modelo, en fin si, por favor si me pueden ayudar les estaré muy agradecido.

    Read the article

  • « Un développeur PHP n'est pas moins compétent qu'un développeur Java ou C++ », entretien avec un des co-organisateurs du ZendCon Europe

    « Un développeur PHP n'est pas moins compétent qu'un Java ou un C++ » Entretien avec le co-organisateur du ZendCon Europe A la fin de ses études à l'EPITA en 1999, Philippe Humeau a créé la société NBS System. Pendant 7 ans, elle réalise essentiellement des tests d'intrusions et des audits de sécurité, avant d'ouvrir un département Infogérance en 2006. Depuis, NBS System infogère également plus de 2000 sites de E-commerce en PHP et en Java. Philippe Humeau est également le co-organisateur de la...

    Read the article

  • Julian Assange quittera « sous peu » l'ambassade d'Équateur à Londres où il est réfugié depuis 26 mois déjà

    Julian Assange quittera « sous peu » l'ambassade d'Équateur à Londres où il est réfugié depuis 26 mois déjà Lors d'une conférence de presse Julien Assange, le fondateur de WikiLeaks, a assuré qu'il quittera « sous peu » l'ambassade d'Equateur de Londres où il est réfugié depuis juin 2012 pour échapper à une extradition vers la Suède alors qu'un mandat d'arrêt européen est maintenu contre lui. Pour rappel, le mandat d'arrêt a été lancé fin 2010 à la suite d'une plainte déposée par deux Suédoises...

    Read the article

  • Piratage d'Adobe : la liste aberrante des mots de passe des utilisateurs, plus de 1,9 million de comptes utilisent « 123456 » comme mot de passe

    Piratage d'Adobe : la liste aberrante des mots de passe des utilisateurs plus de 1,9 million de comptes utilisent « 123456 » comme mot de passe En fin du mois dernier, Adobe confirmait avoir subi une cyberattaque d'envergure, ayant entrainé le vol du code source de ses applications Photoshop, Adobe Acrobat, ColdFusion, et la compromission de 38 millions de comptes utilisateurs.Un nouveau rapport vient de jeter un autre pavé dans la mare. L'éditeur ne respecterait pas les meilleures pratiques en...

    Read the article

  • Livre : Mac OS X Snow Leopard, Précis et concis de Nicoletis Nathalie, critique de Marcos Ickx

    Citation: Domptez votre Leopard ! [IMG]http://digitbooks.fr/catalogue/0-couv/9782815001823.png[/IMG] Parue fin août 2009, la version 10.6 de Mac OS X dite Snow Leopard, a été vite adoptée. encore une fois, le monde des systèmes d'exploitation. Avec cette 6e édition, Mac OS X Snow Leopard Précis et concis permettra aux novices comme aux utilisateurs Mac d'anciennes versions de maîtriser rapidement Snow Leopard et ses nouvelles fonctionnalités. Véritable condensé de tout ce qu'il faut savoir sur Leopard, ce guide de po...

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >